Implicitly-deleted constructor error


i am facing a problem which is more a C++ problem.

Call to implicitly-deleted default constructor of 'ofApp'

seems like a default constructor issue but i can’t figure it out as i am not a C++ expert

I have 3 classes :

  • base ofApp
    no custom constructor

  • Creature class
    custom constructor with parameters
    Creature::Creature(ofPoint _pos, int size, ofColor _color)

  • Branch class (of which a Creature is made of)
    custom constructor with parameters
    Branch::Branch(float _length, float _startAngle)

    // Branch
    class Branch {
    public :
    Branch(float _length, float _startAngle);


class Creature {
    Creature(ofPoint _pos, int size, ofColor _color);        
    vector<Branch> branches;


class ofApp : public ofBaseApp{
		void setup();
		void update();
		void draw();
    Creature creature;

void ofApp::setup(){
    creature = Creature(pos, 65, col);

Any clue ?


1 Like

Hi there,

I will try my best to explain wht i think its going on here. You might want to listen to more experienced people though.

So you are creating a class Creature that can be created only if you provide 3 arguments (pos, size, color). Then in ofApp you want tot create an instance to it without providing any argument:

Creature creature;

This is contradictory and the compiler complains.
There are several solutions here.

The first one (not recommended) is to turn that instance into a pointer. so it becomes:

	Creature* creature;

and then in setup you can create the object with new:

creature = new Creature(ofPoint(2,2), 65, ofColor::red);

which means that you will have to delete it at some point, which could lead to difficulties.

The second solution I suggest, i think is cleaner and better, just allow the creation of the class without arguments with a constructor with no arguments, and much better if you give a default value to those parameters (pos, size, color)

Creature() {
	pos = ofPoint();
	size = 0;
	color = ofColor();

Then you can instantiate the class as before, without pointers.

check this
towards the end of this reference you’ll find an example and you’ll understand why it is not working for you.

hope this helps.


thanks a lot for your answers and links.

i also found this links which is quite good.

There are some tips like using an empty default constructor or forward declaration. I kind of get the general idea but it is quite still fuzzy to me.

So i tried the C++11 way

class Creature {
    Creature() = default;
    Creature(ofPoint _pos, int size, ofColor _color);
    vector<Branch> branches;

and it works.

But what is bugging me here is i am creating a default constructor for Creature, but this class includes a vector of Branch objects which also don’t have a default constructor but it works without complaining…

because you are not creating any branch automatically only when pushing them into the vector where you use the constructor with parameters

OK. I thought if i create a vector of 10 branches, this would create 10 instances of Branch like Branch branch would do…

yes, resize for example shouldn’t work but as long as the vector is empty and you push the elements one by one the default constructor is not being used

Ok, i get it.
One more thing learned :wink:
Thanks a lot and have a nice day.