Hi there,
I'm having a little trouble getting this, so please excuse me if my question and description sounds confusing or juvenile.
I'm creating a new class called 'Rec'.
And essentially I want to reuse the same instance object (myInstance) every time. So it would be created the first time i initiate the constructor, but the following times it would just refer back to the same one.
But my question is, how do I actually go ahead to declare a new Rec instance in my Main method? As in, what does that actual line of code look like? I can't figure out how to use this constructor: static Rec* instance();
Thanks a lot for your help
I'm having a little trouble getting this, so please excuse me if my question and description sounds confusing or juvenile.
I'm creating a new class called 'Rec'.
And essentially I want to reuse the same instance object (myInstance) every time. So it would be created the first time i initiate the constructor, but the following times it would just refer back to the same one.
Code:
//the specification
class Rec {
public:
~Rec();
static Rec* instance();
protected:
Rec();
private:
static Rec* myInstance;
};
Thanks a lot for your help
Comment