【发布时间】:2013-04-20 12:36:07
【问题描述】:
这是基于 GCC/G++ 并且通常在 Ubuntu 上。
这是我完成的示例程序:
#include <iostream>
using namespace std;
int main()
{
std::string c = "Test";
cout << c;
return 0;
}
上面的代码运行良好。
但我有两个问题我不太明白......
将字符串声明写为
std:string(带有一个:)也可以正常工作。有什么区别?如果我在类中使用
std:string(带有一个:)来声明私有变量,则会收到错误错误:'std' 没有命名类型。此声明的示例:
class KType
{
private:
std:string N;
};
谁能解释一下这些问题? 非常感谢!
【问题讨论】:
标签: c++ string private-members