I think this goes here. Yeah, it does.
Anyway, I always have trouble with this. Say, I make a class called "super.h" and it looks like this (note: this is just an example, I am not working on something like this):
"super.h"
1 2 3 4 5 6 7
|
class super{
public:
super(sObject);
private:
int a, b;
super sObject;
};
|
And then I make a second class "cl.h" and it looks like this:
"cl.h"
1 2 3 4 5 6
|
class cl{
public:
cl();
private:
int c, d;
};
|
and then I make... a calculator function in the "super.cpp" (assume I prototyped it in "super.h".
1 2 3 4 5 6 7 8 9 10
|
void super::calculator()
{
cout<<"A: ";
cin>>a;
cout<<endl<<"B: ";
cin>>b;
cout<<endl<<endl<<a+b;
}
|
Then I make the same thing in "cl.cpp":
"cl.cpp"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include "super.h"
#include "cl.h"
#include <iostream>
using namespace std;
cl::cl(sObject)
: sObject.a(c), sObject.b(d)
{
}
void cl::cl_calculator()
{
sObject.calculator();
}
|
I don't think that even works, but i am in a rush and made a quick little program in Code::Blocks, so I didnt really pay close attention. Anyway, it wouldnt let me use
sObject.a and set it to
c, the debugger would always say, "a member is private." I know it is but how do I make it to where it can work? Remember I am in a rush and didnt pay attention to this so I may edit it when I have time in the morning.