Lets say I have
struct someStruct
{
int a;
};
and 2 classes.
In the method in first class I create an instance of the structure:
someStruct structName;
now I want to pass the address of this struct to the constructor of another class
std::auto_ptr<2ndClass> 2ndClass_ (new 2ndClass(structName));
I want to use struct values changed in 2ndClass here - read below...
The second class has:
header:
...
class 2ndClass...
...
private:
someStruct &structName2;
public:
__fastcall 2ndClass(someStruct &structName);
...
cpp:
__fastcall 2ndClass::2ndClass(someStruct &structName)
: structName2(structName)
{
...
This obviously makes a copy of structName.
My question is: How can I assign an address to structName2 from structName so I can read and write into the structure, and then use those values in the first class after leaving the second class? How can I do it without using pointers to the structure?