As already mentioned, this is basic C++. There are some good free books online that will explain object oriented programming. You just need to take a little bit of time and read some chapters about it. It's boring, I know, but it's necessary.
Sharing data between classes is actually very easy.
Class1
{
public:
Class1{}
~Class1{}
void doSomething();
int getValue() const;
private:
int m_value;
};
Class1::Class1()
{
m_value = 1;
}
void Class1::doSomething()
{
m_value = 2;
}
int Class1::getValue() const
{
return m_value;
}
Class1
{
public:
Class1{}
~Class1{}
void doSomething();
int getValue() const;
private:
int m_value;
};
Class1::Class1()
{
m_value = 1;
}
void Class1::doSomething()
{
m_value = 2;
}
int Class1::getValue() const
{
return m_value;
}
To copy to clipboard, switch view to plain text mode
Then from anywhere else in the code, you can do:
Class1 *myClass1 = new Class1;
myClass1->doSomething();
int theValue = myClass1->getValue();
delete myClass1;
Class1 *myClass1 = new Class1;
myClass1->doSomething();
int theValue = myClass1->getValue();
delete myClass1;
To copy to clipboard, switch view to plain text mode
Bookmarks