bst said:
Is there a way to iterate through member variables of different names, of
course, one by one from the very first one in a while loop, for example?
Thanks!
I'm probably doing something stupid, but did you mean something like this?
Even if something's wrong with it (and there probably is), at least I'll
learn something when everyone corrects me
One thing I do know that's wrong is the public member variables in both
classes, but I left those in so that I could fool around with it (and I
can't think of any other way to make this setup work). [snip]
class Reader {
public:
Reader(ReadMe& readFromThis) : target(readFromThis) { }
void printTargetVars() const;
ReadMe& target;
};
void Reader:
rintTargetVars() const {
int* arr[4] = { &target.var1, &target.var2, &target.var3, &target.var4 };
int i = 0;
while(i < 4) {
cout << *arr
<< "\n";
++i;
}