C++ 在C+;中的头文件和Cpp文件中使用类+;

C++ 在C+;中的头文件和Cpp文件中使用类+;,c++,C++,我得到一个名为Node.h的头文件,其定义如下: #ifndef NODE_H #define NODE_H #define MAX_RESISTORS_PER_NODE 5 class Node { private: int numRes; // number of resistors currently connected int resIDArray[MAX_RESISTORS_PER_NODE]; // stores the index of each resis

我得到一个名为Node.h的头文件,其定义如下:

#ifndef NODE_H
#define NODE_H

#define MAX_RESISTORS_PER_NODE 5


class Node
{
private:

    int numRes; // number of resistors currently connected
    int resIDArray[MAX_RESISTORS_PER_NODE]; // stores the index of each resistor
    int *max_number_of_resistors;
    int *max_number_of_nodes;


public:
    Node();
   ~Node();
   // Updates resIDArray to show the resistor in position rIndex in
   // the resistor array is now connected to this node.
   // Returns true if successful
    bool addResistor (int rIndex);

   // prints the whole node
   // nodeIndex is the position of this node in the node array.
        void print (int nodeIndex);

};

#endif  /* NODE_H */
但是,没有为构造函数设置参数,因此如何将max_number_of_电阻器初始化为另一个cpp文件获得的值?我是否可以在这个头文件get_data(int node,int res)和我的node.cpp文件中创建一个新函数,并执行以下操作:

#include <Node.h>
get_data(int node, int res)
{
     max_number_of_resistors = new int[res];
     max_number_of_nodes = new int[node];

}
您是否尝试过初始化列表

您是否尝试过使用参数创建另一个构造函数

Node (unsigned int maximum_resistors)
: numRes(maximum_resistors)
{ ; }


我想说初始化将来自
#定义每个节点的最大电阻5
你必须把它交给那些导师-他们很有想象力。实际上每个节点的最大电阻意味着连接到单个节点的最大电阻是5,但用户输入有多少个节点以及有多少个电阻
Node()
: numRes(MAX_RESISTORS_PER_NODE)
{ ; }
Node (unsigned int maximum_resistors)
: numRes(maximum_resistors)
{ ; }
Node (unsigned int maximum_resistors)
{
   numRes = maximum_resistors;
}