#include <iostream> #include<string> using namespace std; class String { public: String(const char *str=NULL); String(const String &r); ~String() { cout<<"xigou"<<mydata<<endl; } int getSize(); private: char *mydata; int size; }; String::String(const char *str) { cout<<"gouzao "<<str<<endl; size=sizeof(str); } String::String(const String &r) { size=r.size; mydata=new char[size]; for(int i=0;i<size;i++) { mydata[i]=r.mydata[i]; } cout<<"kaobei gouzao"<<mydata<<endl; } int main() { String s1,s2("hello"); String s3(s2); return 0; }
qq_啊你竟然丶_0
相关分类