Page 1 of 1

[Snek Game] Constructor cannot be referenced

Posted: July 28th, 2017, 10:40 pm
by AceEternus
In Tut20 pt2 when I create the brick array. I get asked to create a default constructor for the Brick class but when I do it says error C2280: 'Brick::Brick(void)': attempting to reference a deleted function also Brick::Brick(void)': function was implicitly deleted because a data member 'Brick::rect' has either no appropriate default constructor or overload resolution was ambiguous (compiling source file Game.cpp)
Any ideas?

Re: [Snek Game] Constructor cannot be referenced

Posted: July 28th, 2017, 11:08 pm
by albinopapa
You didn't post your code, so I'm going to assume this is your issue.

Re: [Snek Game] Constructor cannot be referenced

Posted: July 29th, 2017, 12:42 pm
by AceEternus
Not exactly.
Here's the code now if you go in game.cpp to the Game constructor you'll find the error saying "Error1790: The default constructor of "Brick" cannot be referenced -- it is a deleted function"
I'm not sure how to fix this error I thought about removing the Brick constructor completely and using a factory function to init the bricks but I get asked to create a default constructor.
I even made an entire BrickWall class that includes the Brick class to take care of the initialising and such but still the same error when I create the BrickWall object in the Game class.
Hope I didn't confuse you because I'm confused myself :lol:
PS. I'm using Visual Studio 2017

Re: [Snek Game] Constructor cannot be referenced

Posted: July 29th, 2017, 2:32 pm
by AceEternus
And I just realised I put Snek Game in the title my bad was talking about Fart-Annoyed

Re: [Snek Game] Constructor cannot be referenced

Posted: July 29th, 2017, 6:13 pm
by albinopapa
Add this to ShapeRect and you're golden
ShapeRect() = default;

Re: [Snek Game] Constructor cannot be referenced

Posted: July 29th, 2017, 6:37 pm
by AceEternus
I am so grateful man. This whole constructor is such a hindrance.
I wish Chili could talk more about it.
Anyway I really appreciate your help man!

Re: [Snek Game] Constructor cannot be referenced

Posted: July 29th, 2017, 7:33 pm
by albinopapa
He does in other episodes.