#ifndef OBJ_H
#define OBJ_H
#include <iostream>
#include <string>
using namespace std;
class obj {
public:
explicit obj(string st) :str(st) {
}
void print() {
cout << str << endl;
}
private:
string str;
};
#endif
#include"obj.h"
class objcontainer {
public:
objcontainer(string str) :o(str){}
objcontainer( obj ob) {
}
obj *operator->()
{
return &o;
}
private:
obj o;
};
objcontainer( obj ob) {
o=ob;
//提示obj没有默认构造的函数,这不是拷贝函数么?
}
objcontainer( obj ob):o(ob) {
//这样又对了
}