A question about classes in C++
-
- Posts: 5
- Joined: October 7th, 2017, 8:32 am
A question about classes in C++
Hi guys! I've been watching "Beginner C++ Game" tutorials for some time now and i've got a question about classes. So, when we want to call a function from let's say "Graphics" class, inside ComposeFrame() for example, what's the difference between "gfx.PutPixel()" and "Graphics::PutPixel()" ?
Re: A question about classes in C++
Graphics::Func() works only for static functions--functions that are part of the class but do not operate on an object of the class. gfx.Func() is used to call (or invoke) a non-static member-function on a particular instance of the class (an object of the class).
(The gfx.Func() syntax can be used for static functions as well, but the gfx. part is meaningless and it is exactly the same as Graphics::Func())
(The gfx.Func() syntax can be used for static functions as well, but the gfx. part is meaningless and it is exactly the same as Graphics::Func())
Chili
-
- Posts: 5
- Joined: October 7th, 2017, 8:32 am
Re: A question about classes in C++
I see...Thanks for the reply Chili :=) Keep doing what you're doing!chili wrote:Graphics::Func() works only for static functions--functions that are part of the class but do not operate on an object of the class. gfx.Func() is used to call (or invoke) a non-static member-function on a particular instance of the class (an object of the class).
(The gfx.Func() syntax can be used for static functions as well, but the gfx. part is meaningless and it is exactly the same as Graphics::Func())