调用构造函数后程序崩溃
Program crashes after constructor is called
template<class item_type> struct node{
item_type x;
node<item_type> *left;
node<item_type> *right;
int Get_Height();
int Get_Num_Nodes(); };
template<class item_type, class param> class Tree{
node<item_type> *root;
public: // some functions
Tree(int roo);
我有一个将节点作为叶子的树类。Tree(int roo( 是构造函数。
template<class item_type, class param>
Tree<item_type, param>::Tree(int roo)
{
this->root->x=roo;
this->root->left=NULL;
this->root->right=NULL;
}
这是构造函数的暗示。我还尝试同时省略 root->left=NULL
和 right 相同,以及没有构造函数并使用默认构造函数。
当我在main()
中运行Tree<int, int> durr(1);
时,所有这些似乎都会使我的程序崩溃
似乎看不出问题,我是一个新手程序员。任何帮助将不胜感激。
使用 this->root = new node<item_type>
初始化*root
相关文章:
- 提升 ASIO Async_receive崩溃程序
- 类指针方法崩溃程序
- get_body来自 IHTMLDocument2 崩溃程序
- 是否有可能存在不会崩溃程序的内存问题
- 调试运行时出现奇怪的崩溃程序(Eclipse C++)
- 儿童对话框 - setWindowTexta或sendmessagea崩溃程序-MFC
- 顶点阵列GLFW崩溃C 程序
- 将值分配给Float数据类型崩溃程序
- OpenCV-将变量添加到类成员崩溃程序
- boost::interprocess::managed_shared_memory 崩溃程序
- 将枚举值分配给整数崩溃程序
- SDL 1.2 -> SDL 2.0(崩溃程序)
- 空析构函数崩溃程序:C++
- 冒泡排序崩溃程序c++
- Ofstream关闭崩溃程序
- 删除字符* 崩溃程序
- c++矢量擦除崩溃程序
- Lua_getglobal崩溃程序
- 通过Copy Constructor创建的e2打印崩溃程序
- RNG崩溃c++程序