I would like to know what is wrong with the following C++ code. It crashes on Run.
#include <iostream.h>
#include <conio.h>
using namespace std;
class node
{
public:
int info;
node *addr;
node(){
info = 0;
addr = NULL;
}
~node(){}
};
void func(node *);
int main(void){
node *head;
node b;
b.info = 10;
*head = b;
func(head);
getch();
}
void func(node *obj){
cout<<"i: "<<(*obj).info;
}
is not correct since head doesn’t point to anything
should solve the problem