I think you want to declare testString as static. That way every instance of the class will reference the same instance of testString.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
try this out
class MyClass
{
public:
MyClass(int& xx) : x(xx){};
private:
int& x;
};
int main()
{
int x;
MyClass c(x);
}
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
AFAIK Must be done in the constructor.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343