anything wrong with this? (constructor abuse)

ofProjector::ofProjector() {
*this = ofProjector(1024, 768);

then it uses the other constructor ofProjector::ofProjector(int width, int height);

for some reason or other i wouldn’t want to use defaults on the arguments

i’m just curious if this is abusive in any way

generally i’d like a way for constructors to call other constructors


don’t know if your hack will work, but what is wrong using a private method, which gets called by all of your constructors?

class Test {  
    Test(int i, int j) { construct(i,j); }  
    Test() { construct(1,2); }  
    Test(const Test2& t2) { construct(t2.getI(), t2.getJ()); }  
     void construct(int i, int j) { 



some addendum:

if you are willing to switch to C++11, you can call other c’tors, see


ah great!
i was wondering why that was missing from c++ in the first place
i’m making an addon so it’s probably best to avoid compiler specific functioanlity

i usually go via a seperate function, but the hack seemed intriguing (and works fine so far in vs2010 / xcode-llvm)