What i am trying to do here is to pass an argument from int main() to num2 then using the same value pass the argument to num1 but the compiler is acting like the arguments passed to num1 does not belong to the class' private member. What's the problem and what is the problem's name? I want to find it in the net or textbook.
Code:
#include<iostream>
#include <string>
using namespace std;
class num1
{
int a;
int b;
public:
num1(int h,int g):a(h),b(g){};
int addnum()
{
return a+b;
}
};
class num2
{
num1 c( int x, int y);
public:
num2 (int a, int b)
{
x=a;
y=b;
}
int funct()
{return c.addnum();}
};
int main()
{
num2 f(1,2);
cout<<f.funct();
return 0;
}