Hello DaniWeb, I'm relatively new to DaniWeb, and recently decided to come back to an attempt at learning to C++. I just finished reading a particular section on OOP etc. and i have some questions about pointers to objects: like:

MyClass *Object;

Can someone please:

1) Explain why this is used - what are the pros/cons?
2) Perhaps provide a link to a good tutorial on it? Or provide some background information on how to use this correctly.

Any help would be greatly appreciated, as you can see, im a lil bit of a newb (:

>1) Explain why this is used - what are the pros/cons?
That's quite a broad question. Can you be more specific about what you learned and what part of it is confusing?

This is a tutorial that I wrote. It's more of an overview of pointers in general, but it might answer some of your questions.

Comments
put simply, that tut is all anyone will ever need for pointers :)

hi all,

I Asked my self this question last time ,
see,
our memory strategy as stack , or as heap , if you work as simple project you can use stack - , but it is slow when the project big or be as enterprise one,

so the heap strategy will be the best ,
so we use pointers
like

//HEAP
yclass *object = new Myclass(); //object is on the heap
//STACK
Myclass object; //object is on the stack

hi all,

I Asked my self this question last time ,
see,
our memory strategy as stack , or as heap , if you work as simple project you can use stack - , but it is slow when the project big or be as enterprise one,

so the heap strategy will be the best ,
so we use pointers
like

//HEAP
Myclass *object = new Myclass(); //object is on the heap
//STACK
Myclass object; //object is on the stack

Edited 6 Years Ago by palunix: n/a

Comments
The exact answer i needed

Hmm thanks to both of you that was extremely helpful, especially that lengthy tutorial - exactly what i needed right now :) Also, palunix, ty that finally got my head round the issue in particular.

Edited 6 Years Ago by Your_mum: n/a

This article has been dead for over six months. Start a new discussion instead.