【发布时间】:2014-08-01 01:04:00
【问题描述】:
我正在使用 MinGW-w64 和 4.8.1(使用 -std=c++11)并尝试在同一类的另一个构造函数中调用我的类的一个构造函数。不幸的是,我没有编译下面的代码。
A::A(const char *pc) {
A(string(pc));
}
A::A(string s) {
vector<string> tmpVector;
tmpVector.push_back(s);
A(tmpVector);
}
// Constructor
A::A(vector<string> filePathVector) {
}
以下是 GCC 抱怨的错误。
In file included from ../parser/nsn/parser.h:37:0,
from main.cpp:2:
../parser/nsn/parserimp.h: In constructor 'A::A(std::string)':
../parser/nsn/parserimp.h:522:29: error: conflicting declaration 'A tmpVector'
A(tmpVector);
^
../parser/nsn/parserimp.h:520:17: error: 'tmpVector' has a previous declaration as 'std::vector<std::basic_string<char> > tmpVector'
vector<string> tmpVector;
我已经阅读了 C++11 中的委托构造函数概念,但我不确定这就是我所追求的......
【问题讨论】:
标签: c++ gcc c++11 constructor