September 9th, 2003, 05:12 AM
Vector, pointers, pointer to vector, vector of pointers? Access class attribute...
I've got these 3 classes:
Most of my experience of programming is in Java, but I've got to make a bit of programming in VC++ and I've got a problem (lack of experience) with pointers, and C++ stuff.
I want to access a property/attribute of the APIObject class. So I did this:
//Created a vector of APIDomain Objects:
//Fill a position of this vector:
APIDomain toAddAPIDomain; //Temp. APIDomain object
toAddAPIDomain.domainName = valueX;
//Now add a APIObject to the parameter objects(vector of APIObject) of the APIDomain object.
//I'm having some problems with this one...
tmpVectorAPIObject = domains[domainIndex].objects;
With the above code, I'm not inserting into the domains object, but in the temporary variable !?!??! (In Java the above code would create a pointer to the position of the attribute, any changes made to the temp. vars would be reflected in the domains object)
The code below works, but I prefer to create a temporary var so that the code becomes more simple to read (If I try to get an attribute of the APIMethod this line becames too large)
How can I solve this problem?
I want to create a temporary variable and work with it, so that any changes made to the temp. variable are made directly to the original object.
I know that I must use a pointer to solve this, but what should I do?
Modify the classes that I've created (instead of vector use a vector *)?
Or there is a way of creating a temporary variable that points to the vector attribute of the class?