[Snek Game] Constructor cannot be referenced

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
AceEternus
Posts: 6
Joined: July 21st, 2017, 5:06 pm

[Snek Game] Constructor cannot be referenced

Post by AceEternus » July 28th, 2017, 10:40 pm

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?

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: [Snek Game] Constructor cannot be referenced

Post by albinopapa » July 28th, 2017, 11:08 pm

You didn't post your code, so I'm going to assume this is your issue.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

AceEternus
Posts: 6
Joined: July 21st, 2017, 5:06 pm

Re: [Snek Game] Constructor cannot be referenced

Post by AceEternus » July 29th, 2017, 12:42 pm

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
Attachments
Fart-Annoyed.zip
Code
(2.37 MiB) Downloaded 119 times

AceEternus
Posts: 6
Joined: July 21st, 2017, 5:06 pm

Re: [Snek Game] Constructor cannot be referenced

Post by AceEternus » July 29th, 2017, 2:32 pm

And I just realised I put Snek Game in the title my bad was talking about Fart-Annoyed

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: [Snek Game] Constructor cannot be referenced

Post by albinopapa » July 29th, 2017, 6:13 pm

Add this to ShapeRect and you're golden
ShapeRect() = default;
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

AceEternus
Posts: 6
Joined: July 21st, 2017, 5:06 pm

Re: [Snek Game] Constructor cannot be referenced

Post by AceEternus » July 29th, 2017, 6:37 pm

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!

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: [Snek Game] Constructor cannot be referenced

Post by albinopapa » July 29th, 2017, 7:33 pm

He does in other episodes.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply