#include <iostream>
usingnamespace std;
class Classy
{
public:
int TakeANumber() { return NO; }
void GiveANumber(int input){ NO = input; }
private:
int NO = 0;
};
class Classy2
{
public:
void FeedClass(Classy T) { HoldClass = &T; }
int Return() { return HoldClass->TakeANumber(); }
private:
Classy *HoldClass;
};
void main()
{
Classy John;
Classy2 Bill;
John.GiveANumber(12);
Bill.FeedClass(John);
cout << Bill.Return() << endl;
cin.get();
}
This compiles just fine, but the output is definitely not what I'm looking for (should be 12)
I hope this post comes out correctly..
Thank you!
Edit: I relized I have no comments which is a pain for people to look at, so here is a rundown of what it's supposed to do with comments:
1 2 3 4 5 6 7 8
Classy John; // make a class object John
Classy2 Bill; // make a class object Bill
John.GiveANumber(12); // feed a number for John to hold on to
Bill.FeedClass(John); // Tell Bill where the Class John is so it can acess it's functions.
cout << Bill.Return() << endl; // ask bill what the number is that John was holding.
cin.get();