我读过其他类似的帖子,但我不明白我做错了什么.我认为我对载体的声明是正确的.我甚至试图宣布没有大小,但即使这样也行不通.出了什么问题?我的代码是:
#include <vector>
#include <string>
#include <sstream>
#include <fstream>
#include <cmath>
using namespace std;
vector<string> v2(5, "null");
vector< vector<string> > v2d2(20,v2);
class Attribute //attribute and entropy calculation
{
vector<string> name(5); //error in these 2 lines
vector<int> val(5,0);
public:
Attribute(){}
int total,T,F;
};
int main()
{
Attribute attributes;
return 0;
}
Run Code Online (Sandbox Code Playgroud) 你怎么能创建一个2D数组,比如arr[][]5行,每行中的列数可变?
可能arr[5][]
是第一行arr[0][]有4列
第2行arr[1][]有5列,依此类推?
我不介意STL矢量解决方案,但我还不太了解矢量.
我正在使用Qt创建者2.4.我需要hi"world"在我的代码中使用字符串.我试图使用Qstring和std::string我知道/是转义序列字符,但IDE不理解它作为转义序列并在我写时出错:
"hi/"world/""
Run Code Online (Sandbox Code Playgroud)
我可以使用任何可以转换成的字符串格式Qstring.我有什么想法我做错了吗?