Dlo*_*ker 19 c++ gcc cygwin compilation vector
我正在使用Cygwin与GCC,最终我想在一个字符文件中读入一个字符向量,并使用此代码
#include <fstream>
#include <vector>
#include <stdlib.h>
using namespace std;
int main (int argc, char *argv[] )
{
vector<char> string1();
string1.push_back('a');
return 0;
}
Run Code Online (Sandbox Code Playgroud)
生成此编译时错误:
main.cpp:在函数
int main(int, char**)': main.cpp:46: error: request for memberpush_back'中的string1', which is of non -class typestd :: vector>()()'
我用一个int和字符串向量尝试了这个,他们有同样的问题.
Geo*_*che 44
不要使用括号来调用默认构造函数:
vector<char> string1;
Run Code Online (Sandbox Code Playgroud)
否则,这将声明一个string1不带参数并返回a 的函数vector<char>.
| 归档时间: |
|
| 查看次数: |
23442 次 |
| 最近记录: |