here is my code:
vector *ptr;
int *tab = new int(20);
ptr->push_back(tab);
cout << *(ptr->at(0)) << endl;
I want to print 20 on the screen, but I got a segmentation fault.
when I use only
vector ptr;
it prints out fine. I get easily the result just by doing :
*ptr.at(0);
But I want to use a pointer not a simple variable.
Can I have some enlightenment?
Thanks
No comments:
Post a Comment