so say I have something like this:
#include<iostream>
class A{
public:
void setErrorMessage(char*);
}
void A::setErrorMessage(char* errMessage){
// code here to set B::errMsg
}
class B{
public:
A someObject[3];
char* errMsg;
}
int main(int argc,char** argv){
B something;
B another;
something.someObject[2].setErrorMessage("BIG ERRAR!");
another.someObject[0].setErrorMessage("everything's okay!");
cout<< something.errMsg<< endl;
cout<< another.errMsg<< endl;
return 0;
}
This is of course a useless code, but I'm using something like it in a larger situation...
Anyways, if I create a class A, and then use it to create an object in another class B, and then create an object C of class B--C.A generates an error and needs to set the (not static--otherwise it'd be easy) error message to C, and specifically the object C, and leave the errMsg variable of other instances of B alone.
Can it be done?