Dynamic Memory Allocation!!!

Pages: 12
new returns a pointer. A pointer.

If you want this to work:

ID = new int;

then ID must be a pointer to an int.
yes i also tried this but this will effect my setters and getters functions..
1
2
3
4
5
6
7
8
9
void setID()
{
cout<<"Enter ID: ";
cin>>ID; //error on this step
}
void getID()
{
return ID; //also error on this step
}


then how to fix errors on these steps???
closed account (S6k9GNh0)
You need to go back to the basics. C++ is not a language you should just guess at everything with as you'll get nowhere. Go read an in-depth book on C++ or programming in general. Also, make sure they teach the basics such as pointers and pointer arithmetic.
Last edited on
then how to fix errors on these steps???


By learning how to use pointers. As computerquip says, if you don't know what a pointer is, you are not ready for dynamic memory.
OK.....i think you guys are right i need strong concepts on pointers.......Thanks for help!!!
Topic archived. No new replies allowed.
Pages: 12