【发布时间】:2014-04-14 21:47:42
【问题描述】:
我不知道发生了什么。该程序似乎在视觉工作室上运行良好。也许我做错了什么,我找不到它。请有人帮我解决这个问题。
#include <iostream>
#include<string>
#include<cstdlib>
using namespace std;
class Aokiji
{
private:
string name1;
string name2;
public:
string setName(string x)
{
name1=x;
}
string getName()
{
return name1;
}
};
int main()
{
Aokiji Grapes;
Grapes.setName("I got it!");
cout<< Grapes.getName()<< endl;
system("pause");
}
【问题讨论】:
-
描述崩溃。是SegFault吗?调试器会告诉您有关崩溃的哪些信息?
-
在visual studio中可以正常使用,但是在什么环境下不行?
-
getName() 应该是 const
标签: c++ string function class operators