Sign in to follow this  

Confused with Class snip code... (C++)

This topic is 4108 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am some little confused on this snip code CDXSprite *title=0; // declare variable name title which is pointer pointed to Class CDXSprite title=new CDXSprite(); Reserved memory at Heap then let title pointed to that memory location. I am confused that "why we have sign"( )" after class???" Or it not class but CDXSprite()is function? ... if right, oh!! can we reserved memory for function? title->Create(Screen,"title.bmp",640,480,CDXMEM_VIDTHENSYS); // call function via pointer Thank you for every answer

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by eniCma
I am some little confused on this snip code

CDXSprite *title=0; // declare variable name title which is pointer pointed to Class CDXSprite

and make it a null pointer...

Quote:
Original post by eniCmatitle=new CDXSprite(); Reserved memory at Heap then let title pointed to that memory location. I am confused that "why we have sign"( )" after class???" Or it not class but CDXSprite()is function? ... if right, oh!! can we reserved memory for function?


read up on C++ classes (OOP)
You are explicitly calling the default constructor, which is both: a function (method) and part of a class.




Share this post


Link to post
Share on other sites
Guest Anonymous Poster
... IOW, in this case you could also omit the brackets, as you aren't passing any arguments.

Share this post


Link to post
Share on other sites

This topic is 4108 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this