Page 1 of 1

A question about classes in C++

Posted: October 7th, 2017, 8:38 am
by eagerStudent
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++

Posted: October 7th, 2017, 8:53 am
by chili
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())

Re: A question about classes in C++

Posted: October 8th, 2017, 5:39 am
by eagerStudent
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())
I see...Thanks for the reply Chili :=) Keep doing what you're doing!