C++

//Note: The code in the code template will be copied to any newly created file, edit the code in the code template and let him automatically add fixed code for you
#include
using namespace std;
class B;
class A
{
int a;


int b;
public:
A(int x,int y):a(x),b(y){}
A(B &aa)
{
a=aa.a;
b=aa.b;
cout<<a< <b;
}
};
class B
{
int a;
int b;
public:
B(int x,int y):a(x),b(y){}
B(A &bb)
{
a=bb.a;
b =bb.b;
cout<<a<<b;
}
};
int main()
{
A h(1,2);
B g(3,4);
A f(g);
B j(h);
return 0;
}
//Note: the code in the code template will be copied to any newly created file, edit the code in the code template and let him automatically add fixed code for you
#include
using namespace std;
class A
{
int a;
int *p;
public:
A(int x){a=x;p=new int(1);cout<<*p;}
A(A &aa)
{
a=aa.a;
p=new int (2);
cout<<a<<' '<<p;
}
~A()
{delete p;}
};
int main()juu
{
A s(1);
A d(s);
return 0;
} //Note: The code in the code template will be copied to any newly created file, edit the code in the code template and let him automatically add fixed code for you
#include
using namespace std;
class A
{
int a;
public :
A(int a){a=a;cout<<a;}
};
int main()
{
A g(2);
return 0;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324482618&siteId=291194637
C++