#include <iostream>
using namespace std;
struct intHolder
{
int *val;
};
class CIntHolder
{
public:
CIntHolder() : theInt(0) {}
~CIntHolder() { theInt = 0; }
void set(intHolder &ih) { ih.val = &theInt; }
void load(intHolder &ih) { theInt = 1; set(ih); }
int getInt() { return theInt; }
private:
int theInt;
};
void changeInt(intHolder *toChange)
{
*(toChange->val) += 1;
}
int main()
{
CIntHolder myCIntHolder;
intHolder ih;
myCIntHolder.set(ih);
cout << "class internal: " << myCIntHolder.getInt() << endl;
cout << "my copy: " << *ih.val << endl;
changeInt(&ih);
cout << "class internal: " << myCIntHolder.getInt() << endl;
cout << "my copy: " << *ih.val << endl;
return 0;
}