I definitely remember seeing somewhere an example of doing so using reflection or something. It was something that had to do with SqlParameterCollection which is not creatable by a user (if I'm not mistaken). Unfortunately cannot find it any longer.
Can anyone please share this trick here? Not that I consider it a valid approach in deve...
Following up on this question, people have suggested I go with "option 3" which might look like this:
class b2Body {
private:
b2Body() {}
friend class b2World;
};
class Body : public b2Body {
private:
Body() {}
friend class World;
};
class b2World {
public:
b2Body *CreateBody() {
return new b2Body;
}
};
class World : public b...
Yet another question, go me!...
Anyway, I have 2 classes with private constructors and static functions to return an instance of that class.
Everything was fine, I have a main.cpp file where I managed to get hold of my gameState object pointer, by doing:
gameState *state = gameState::Instance();
But now I seem to have a problem. For t...
Hi
We can restrict the creation of object of a class by making its constructor private.
But this constructor could still be called from within the class.
Is there any way to prevent this in Java?
Thanks.
...
In reading TCPL, I got a problem, as the title refered, and then 'private' class is:
class Unique_handle {
private:
Unique_handle& operator=(const Unique_handle &rhs);
Unique_handle(const Unique_handle &rhs);
public:
//...
};
the using code is:
struct Y {
//...
Unique_handle obj;
};
and I want to execute such op...
Possible Duplicate:
How to use a object whose copy constructor and copy assignment is private?
In reading TCPL, I got a problem, as the title refered, and then 'private' class is:
class Unique_handle {
private:
Unique_handle& operator=(const Unique_handle &rhs);
Unique_handle(const Unique_handle &rhs);
public:...
I would like to call a static method from a class that I'll determine at run-time, but which I know subclasses a given class. So let's say I have these classes
class super {
public:
super();
static super *loadMe (ifstream &is);
}
class subA : public super {
public:
subA();
static super *loadMe (ifstream &is);
}
c...