C++ C++;构造函数重载-为什么它说我需要括号?
以下是我的头文件的代码:C++ C++;构造函数重载-为什么它说我需要括号?,c++,debugging,constructor,C++,Debugging,Constructor,以下是我的头文件的代码: #ifndef NEURAL_NETWORK_H #define NEURAL_NETWORK_H #include <vector> #include "genome.h" #include "node.h" class NeuralNetwork { protected: std::vector<Node> m_nodes; public: NeuralNetwork(std::vector<Node> n
#ifndef NEURAL_NETWORK_H
#define NEURAL_NETWORK_H
#include <vector>
#include "genome.h"
#include "node.h"
class NeuralNetwork {
protected:
std::vector<Node> m_nodes;
public:
NeuralNetwork(std::vector<Node> nodes);
NeuralNetwork(Genome genome);
void update();
};
#endif
然而,没有不平衡的括号,我认为代码没有错,我假设这与构造函数重载有关,但是在网上研究之后,似乎没有任何特殊的规则。
还有,当我用int替换基因组时
我使用C++ 11。 你有一个循环依赖性,你需要打破它。人们通常通过使用前向声明来实现这一点 事实上,在
neuralNetwork.h
头文件(如图所示)中没有任何内容需要Genome
的完整定义,这意味着您可以替换
#include "genome.h"
与
您仍然需要
#在源文件中包含“genome.h”
,您可以在其中定义(实现)构造函数。您可以尝试创建一个构造函数并向我们展示吗?可能genome
位于不同的命名空间中?您没有提供足够的信息。这里显示的代码没有明显的错误。
#include "genome.h"
class Genome;