I watch hw3d videos. I am on 11. video . I write all codes which i saw on the video.
While "Graphics" is loaded, i get this error message.
Is there any hidden code which Chili didn't mention on the video?
i get an error C2512 no appropriate default constructor available
-
- Posts: 52
- Joined: April 15th, 2017, 10:48 am
Re: i get an error C2512 no appropriate default constructor available
I didn't get that far with the tutorials yet, but if you need code reference, checking out git commit history sounds like a better idea, rather than picking lines of code from the video.
https://github.com/planetchili/hw3d
https://github.com/planetchili/hw3d
"Idk if im having brain stop anyone have any advice on smart way to check 2 moving many unique step ur taking" ~Petrus
-
- Posts: 52
- Joined: April 15th, 2017, 10:48 am
Re: i get an error C2512 no appropriate default constructor available
The file is attached
- Attachments
-
- hw3d-11.rar
- (3.17 MiB) Downloaded 143 times
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: i get an error C2512 no appropriate default constructor available
The problem is that the Graphics class doesn't have a default constructor, ie
Therefore in Window, you cannot store a Graphics object without initializing it, which you can't really do since it takes an HWND as it's constructor parameter and you don't get the HWND object until after the call to CreateWindowEx.
Chili uses a unique_ptr to a Graphics object to delay the initialization, which you do have, but you also have a Graphics object for some reason.
Code: Select all
Graphics() = default;
Chili uses a unique_ptr to a Graphics object to delay the initialization, which you do have, but you also have a Graphics object for some reason.
Code: Select all
// Chili's code
public:
Keyboard kbd;
Mouse mouse;
private:
int width;
int height;
HWND hWnd;
std::unique_ptr<Graphics> pGfx;
Code: Select all
// Your code
public:
Keyboard kbd;
Mouse mouse;
Graphics gfx;
private:
int width;
int height;
HWND hWnd;
std::unique_ptr<Graphics> pGfx;
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
Re: i get an error C2512 no appropriate default constructor available
I'm pretty sure I took a decent amount of time to talk about the deferred construction of the gfx object ;/
Chili