小编use*_*717的帖子

C++编译时错误:数字常量之前的预期标识符

我读过其他类似的帖子,但我不明白我做错了什么.我认为我对载体的声明是正确的.我甚至试图宣布没有大小,但即使这样也行不通.出了什么问题?我的代码是:

#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)

c++ g++ vector

36
推荐指数
2
解决办法
9万
查看次数

具有可变大小行的C++ 2维数组

你怎么能创建一个2D数组,比如arr[][]5行,每行中的列数可变?

可能arr[5][] 是第一行arr[0][]有4列

第2行arr[1][]有5列,依此类推?

我不介意STL矢量解决方案,但我还不太了解矢量.

c++ arrays vector jagged-arrays multidimensional-array

12
推荐指数
3
解决办法
2万
查看次数

逃脱序列?在Qstring中使用引号

我正在使用Qt创建者2.4.我需要hi"world"在我的代码中使用字符串.我试图使用Qstringstd::string我知道/是转义序列字符,但IDE不理解它作为转义序列并在我写时出错:

"hi/"world/""
Run Code Online (Sandbox Code Playgroud)

我可以使用任何可以转换成的字符串格式Qstring.我有什么想法我做错了吗?

c c++ qt escaping

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

c++ ×3

vector ×2

arrays ×1

c ×1

escaping ×1

g++ ×1

jagged-arrays ×1

multidimensional-array ×1

qt ×1