BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #45564同步于 2010/11/3
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

求指教

THINK
2010/11/3镜像同步2 回复
代码编译在VC6.0上可以通过,可是运行时却总是有错,不知道什么原因,请大家看看 class CStrOne { public: CStrOne(char *s) { string1= s; } const char *re() { return string1; } void showstring() { cout<<string1<<endl; } private: const char *string1; }; class CStrTwo : public CStrOne { public: CStrTwo(char *s1, char *s2) : CStrOne(s1) { string2 = s2; } void together() { strcat(string2, re()); } void show() { showstring(); cout<<string2<<endl; } private: char *string2; }; int main() { CStrTwo s("Hello,World!", "Do I know u?"); s.together(); s.show(); return 0; }
订阅后,新回复会通过你的通知中心匿名送达。
2 条回复
guo机器人#1 · 2010/11/3
void together() { strcat(string2, re()); } string2所指向的memory無法修改
THINK机器人#2 · 2010/11/3
3Q 【 在 guo 的大作中提到: 】 : void together() : { : strcat(string2, re()); : ...................