I want to create a class, which will provide static method to create unique handler (migth be int, might float, might be something but always retrived as a pointer to object), but im still bit confused in my considerations, and when i started to read about singleton and factory pattern, then im confused at all.
Suppose i have a class
CHandle{
private:
CHandle(const CHandle &hnd);
CHandle &operator=(const CHandle &hnd);
static int id;
public:
static CHandle *createHandle(){
id++;
return this;
}
}
in main i would use:
CHandle *c = CHandle::createHandle();
Can i do like that ? Or maybe Im messing up everything ?