classes

Started by
1 comment, last by Rycross 18 years, 4 months ago
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++
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
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.

This topic is closed to new replies.

Advertisement