简体   繁体   中英

Visual Studio 2013 crashing when debugging?

I am currently working on an assignment for my college classes to create an AVL tree with a menu that allows the user to input an item (integer) to add to the tree. The only method I've typed so far is the add routine which passes the users input to an Add routine which then passes it to a method in a class. However, without any syntax errors I can build the solution and it builds somewhat sluggishly. When I hit f5 or try to debug, Visual Studio simply appears to load. It does not crash but I have to force close it in task manager. The code I have is below.

#include "stdafx.h"
#include <iostream>
using namespace std;

struct Node
{
int data;
Node * left;
Node * right;
int balance;
};

typedef Node * ptrNode;

class AVLTree
{
private:
Node * root = NULL;
Node ** trav = &root;

public:

void AddItem(int item);
void deleteNode(int item);
void clearTree();
void inorder();
void showtree();



void Add(int item)
{
    AddItem(root, item);
}
void AddItem(Node *&trav, int item)
{


if (trav == NULL)
    {
        trav = new Node;
        trav->data = item;
    }
    else if (trav->data > item)
    {
        AddItem(trav->left, item);
    }
    else
    {
        AddItem(trav->right, item);
    }
}
};





void main()
{
int choice;
int item;
AVLTree tree;
cout << (This is a menu here, I omitted it since I'm fairly positive it's not causing this)
cin >> choice;

switch (choice)
{
case 1:
    cout << "Enter number to add: ";
    cin >> item;
    tree.Add(item);

    }

    system("pause");
}

I had the same problem while I was trying to run it on my laptop. But the program runs fine on school's computer. Try disable your Anti-virus software temporarily

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM