- #1
butterfli
- 10
- 0
Homework Statement
see #3
Homework Equations
N/A
The Attempt at a Solution
I'm working on this assignment and I got stuck at this part in programming here's what I need to do:
I need to find a way to have one object access the data members of another object.
A broken down/simplified version of my code looks like this:
Code:
class ClassOne
{
public:
ClassOne();
int m_SomeData;
string getData();
};
ClassOne::ClassOne() //setting data to 1
{
m_SomeData = 1;
}
string ClassOne::getData()
{
return m_SomeData;
}
What I want to do is:
Code:
class ClassTwo
{
public:
void showData();
};void ClassTwo::showData()
{
//pseudocode: cout << m_SomeData from ClassOne;
//how do I get this line to work?
}
I know I have to pass in parameters to showData() and possibly dereference but I don't know what to pass in.