I'm not sure how that wrapper should work, my compiler says: `Thing' is not a base of `Person'
But anyway, after a good night's sleep I figured out what was the mistake in my thinking. What I initially wanted to do was something like this:
Suppose I want Person to have another type of data, also contained in a vector, for example std::vector<Oth erThing> otherthings, where OtherThing could be a subclass of Thing or some...
User Profile
Collapse
-
Argh, of course. All the time I just kept thinking that if I declared the vector public, it would expose the data fields of the objects contained in it - but now that I read your suggestion and thought it over, of course it doesn't expose them. Now I feel stupid.
Thanks. =)Leave a comment:
-
Trouble accessing member class' function
[CODE=cpp]
#include <iostream>
#include <vector>
class Thing {
private:
int value;
friend class Person;
public:
int getValue() { return value; }
void setValue(const int val) { value=val; }
Thing (const int val) { value=val; } // Constructor
};
class Person {
private:
...
No activity results to display
Show More
Leave a comment: