继承std::string后的新类没有std::string的特性?[C++] (100分)

  • 主题发起人 real_clq
  • 开始时间
R

real_clq

Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下
#include <string>
class string_c : std::string
{
};
这样声明的string_c并不能得到std::cstring的特性[比如 操作符+的功能]。
这是为什么呢?
 
有没有声明在新类构造函数中调用基类的构造函数,例如下面:
class string_c:public string
{
private:
public:
string_c(char* s):string(s){}
string_c(string s):string(s){}
};
我试过可以对string_c使用+操作符
 
又发现"="不能用。
 
"+"是可以了。
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
959
SUNSTONE的Delphi笔记
S
顶部