【发布时间】:2017-04-04 02:29:54
【问题描述】:
我想知道为什么会出现以下错误:
Main.cpp
int main(int argc, char const *argv[]) {
vector<unsigned> topology = {3, 2, 1};
Net (topology);
/* more code */
}
Net.h
class Net {
public:
Net(const std::vector<unsigned> &topology);
}
错误:
Main.cpp:18:10: error: redefinition of 'topology' with a different type: 'Net' vs 'vector<unsigned int>'
Net (topology);
^
Main.cpp:17:22: note: previous definition is here
vector<unsigned> topology = {3, 2, 1};
^
1 error generated.
如果在 main 中,则该错误已修复,而不是:
Net (topology);
我使用类似的东西:
Net net(topology);
我知道创建要使用的变量更有意义,但是如果出于某种原因我想创建一个矢量
【问题讨论】:
标签: c++ vector constructor neural-network