Hello,
First of all, big thank you to Chili for the great C++ tutorial videos. This is my first post in the forum. Excited!
I encountered a minor issue when trying out Intermediate C++ Game Programming DirectX [Animated Sprite Character] Tutorial 12 on my own. At 8:19, I used implicit call which is Animation ani(0,0,32,48,4,surf,0.1f) instead of Animation marleRight = Animation(0,0,32,48,4,surf,0.1f). I don't get it why implicit call is not allowed here. Vistual studio indicates it expects "type specifiers" instead of parameters in parentheses when I coded "Animation ani()". Any hint is very appreciated.
Implicit call on object declaration
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Implicit call on object declaration
I can't seem to find the exact reason, but it seems that you must use copy initialization or list initialization when giving default values to class members.
Initialization
Copy initialization:
Animation marleRight = Animation(0,0,32,48,4,surf,0.1f);
List initialization:
Animation marieRight = { 0, 0, 32, 48, 4, surf, 0.1f };
Initialization
Copy initialization:
Animation marleRight = Animation(0,0,32,48,4,surf,0.1f);
List initialization:
Animation marieRight = { 0, 0, 32, 48, 4, surf, 0.1f };
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: Implicit call on object declaration
OK. Thanks