【发布时间】:2019-04-14 17:12:26
【问题描述】:
我可以在 main、insert 和 Display By Level 中使用它作为计数器,因为我需要高度或树
class BinarySearchTree
{
public:
Node* root;
int countHight=0; //in this line
BinarySearchTree()
{ root = NULL; }
~BinarySearchTree()
{ return; }
void insert(int value);
void display(Node* temp);
void DisplayByLevel(Node* temp,int level);
};
【问题讨论】:
-
警告信息到底有什么不清楚的地方?如果您有一个较旧的标准编译器,只需使用构造函数初始化器列表来初始化成员变量。
-
嗯,错误说得很清楚。要么使用 c++11 或更高版本编译,要么将
countHight的初始化移到构造函数中 -
您可以添加
-std=c++11编译器选项作为警告消息的建议。如果您不想这样做,请改为在构造函数中设置 countHight=0。
标签: c++ compiler-warnings