Jump to content
  • Advertisement
Sign in to follow this  
eniCma

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

This topic is 4413 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!