2016.11.20 拷贝构造函数

張凌楓<2016.11.20>【连续第4天总结】
A.今日任务
 1.复习构造函数 类和定义
 2.拷贝构造函数
B.具体任务
 1.拷贝构造函数不能重载了嘿
 2.当没有自定义的拷贝构造函数时系统会和构造函数一样自动生成一个拷贝构造函数
 3.拷贝构造函数没有返回值!!!!!!
 4.同类型的对象实例化时,自动调用拷贝构造函数
 5.括号 括号 括号 括号 括号
附代码:
#include <iostream>
#include <string>
using namespace std;
class Mother
{
public:
 string Son()
 {
  return son;
 }
 string son;
 
 Mother(string SON);
 Mother(const Mother &bugbugbug);
};
 Mother::Mother(const Mother &bugbugbug)
 {
  cout<<"烫烫烫烫烫烫烫烫烫烫"<<endl;//出现说明拷贝函数成功!!!!
  }
 
 Mother::Mother(string SON)
 {
  cout<<"成功调用"<<endl;
 }
int main()
{
 string son1,son2;
 cin>>son1;
 cin>>son2;
 
 Mother MarthaWayne(son1);
 Mother MarthaKent(son2);
 Mother F1("23333333333333");//嘲讽一下
 Mother F2 = F1;
 Mother F3(F2);
 
 cout<<F1.Son();
 cout<<"MarthaWayne的儿子是:"<<MarthaWayne.Son()<<endl<<"MarthaKent的儿子是:"<<MarthaKent.Son()<<endl;
 cout<<"不是你妈是他妈 超人他妈也叫玛莎"<<endl<<"你妈是我妈 我去救咱妈!!!"<<endl;
 //哎呀我去 刘老师《超人大战蝙蝠侠》梗
 return 0
}
明日任务
1.依然不变的复习,加上高数啊!!!要考试了QAQ
2.析构函数的学习

博客地址:http://blog.csdn.net/night__day
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值