You are trying to access the i
member of an uninitialized pointer.
You need to allocate memory for b
:
b = new a();
b->i = 1;
a* c= new a(*b);
cout << c->i;
delete b;
delete c;
solved runtime error for c++ code (based on pointers) [closed]
You are trying to access the i
member of an uninitialized pointer.
You need to allocate memory for b
:
b = new a();
b->i = 1;
a* c= new a(*b);
cout << c->i;
delete b;
delete c;
solved runtime error for c++ code (based on pointers) [closed]