标签:函数 blog pre include int bsp stream space print
复制构造函数:
A(const A &other){value=other.value;} 也就是传值参数改为常量引用。
#include<iostream> using namespace std; class A { private: int value; public: A(int n){value=n;} A(const A &other){value=other.value;} void print(){ cout<<value<<endl; } }; int main() { A a=10; A b=a; b.print(); return 0; }
标签:函数 blog pre include int bsp stream space print
原文地址:http://www.cnblogs.com/wft1990/p/6172197.html