c++ - How to use `this` to access member variables in an array of classes -
Looking at a C + + class with mixed member data values and a constant int counter, let me clear a ()
function which can run all the elements of the array of these class objects in clearing their data members. For example, for example, a class that looks like this and keeps the version information of the chip (yes, I know I probably need more satellites and gesters):
class __STA_version_t {public: __STA_version_t () {count ++; }; ~ __STA_version_t () {}; Zero set workstring (four * x) {strncpy (verstring, x, size (versteress)); Verstring [sizeof (verstring) -1] = 0 zero-zeromoststring () {mamet (verstring, 0x0, size (worksstring)); } Char * getVerString () {Return WorstString; } Bool Haversian () {Return verstring [0]; } Zero clear () {for (int i = 0; i
Start somewhere else count
as follows:
__ STA_version_t :: count = 0;
Now, create an array of objects there:
__ STA_version_t version [10]; First, just checking, counting should be equal to 10 after this urgency, correct In clear ()
function, I Want to say something like this:
this [i] - & gt; Explicit credits (); This [J] - & gt; Modification = 0; // e.t.c.
To clear each data member of each element of the array.
Can this be done to work? how?
The issue is that the class can not see its boundaries outside and outside of the container the boundary of the square .
You should use a standard container. Clear the class
method in the class.
There are ways to determine the number of items in the standard container.
See std :: vector
, std :: list
, std :: map
, etc.
Comments
Post a Comment