水水水水水tese

#include
using namespace std;
// g++ Untitled-2.cpp -fno-elide-constructors
class Base {
int data;
public:
Base(int input = 100) : data(input)
{
cout << “Base one construct!” << endl;
}
Base(const Base &in) : data(in.data)
{
cout << “Base copy construct!” << endl;
}
Base(const Base &&in) : data(in.data)
{
cout << “Base move construct!” << endl;
}
virtual void Print()
{
cout << “Base class!” << endl;
}
};
class Derive : public Base {
string name;
public:
Derive(string input = “Derive”) : Base()
{
cout << “Derive one construct!” << endl;
}
Derive(const Derive &in) : Base(in), name(in.name)
{
cout << “Derive copy construct!” << endl;
}
Derive(const Derive &&in) : Base(in), name(in.name)
{
cout << “Derive move construct!” << endl;
}
void Print() override
{
cout << “Print class!” << endl;
}
};
void TFunC(Base in1, Base *in2, Base &in3)
{
cout << “Base in1!” << endl;
in1.Print();
cout << “Base in2!” << endl;
(*in2).Print();
cout << “Base in3!” << endl;
in3.Print();
}

int main()
{
Derive a;
Derive b = a;
Derive *ptr = &a;

TFunC(a, &a, a);
Base c = a; // sliced
// Derive d = c;
cout << sizeof(Base) << endl;
cout << sizeof(Derive) << endl;
system("PAUSE");
return 0;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值