I'd do something like this (when you say Z must remain a pointer, do you mean MyClass::Z or the Z inside Function1?):
Code:
class MyClass
{
public:
MyClass(int &MainX, int &MainY, int &MainZ);
~MyClass() { }
private:
int& X;
int& Y;
int* Z;
};
MyClass::MyClass(int &MainX, int &MainY, int &MainZ) :
X(MainX), Y(MainY), Z(&MainZ)
{
X = 5;
Y = 2;
*Z = 7;
}
void Function1()
{
int X, Y;
int *Z = new int;
MyClass MyVariable(X, Y, *Z);
delete Z;
}
So now your class has references to X and Y. (By the way, references must be initialized in the initialization list instead of inside the constructor, which is why I added that). You also have a pointer to Z. Whenever you change X, Y or *Z inside your class, the variables passed into them will get the new values.
Of course, this is dangerous, since once the function ends and X, Y and Z are destroyed, any time MyClass tries to access them you will get undefined behavior and possibly a crash.
Also, its hard to tell if you understand between '&' the address of operator and '&' meaning reference, and '*' the dereference operator and '*' meaning pointer. If you don't, you might want to read up on that before continuing with whatever you are trying to do.