Jump to content
  • Advertisement
Sign in to follow this  
JasonL220

classes

This topic is 4621 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 have a class that has a function which create a different class eg: class: { class() createImage() modifyImage() ... private: ... } createImage() { image Image(); } modifyImage() { image.change(); } hope you understand :P would that work? btw i'm using C++

Share this post


Link to post
Share on other sites
Advertisement
Showing stuff without context makes it hard to give a good answer here. Why not just use the Image class directly? If you want to have a class that can create other classes you may want to google the Factory design pattern.

==========
Andrew

Share this post


Link to post
Share on other sites
Well the code you posted wouldn't exactly work, but what you're thinking of is called a factory pattern.


public class Factory
{
...
Widget * createWidget() { return new Widget(); }
AnotherWidget * createAnotherWidget() { return new AnotherWidget(); }
};


etc.

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!