为什么explicit vector (size_type n)
表格在课堂外有效,但在课堂内无效?这编译:
#include <vector>
int main() {
std::vector<int> vec_(3); // set capacity to 3
return 0;
}
但不是这个:
#include <vector>
class C {
public:
std::vector<int> vec_(3); // set capacity to 3
};
int main() {
return 0;
}
g++ --std=c++0x -Wall -Wextra -g a.cpp
a.cpp:5:27: error: expected identifier before numeric constant
a.cpp:5:27: error: expected ‘,’ or ‘...’ before numeric constant
为什么?:(