A question about classes in C++

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
eagerStudent
Posts: 5
Joined: October 7th, 2017, 8:32 am

A question about classes in C++

Post by eagerStudent » October 7th, 2017, 8:38 am

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()" ?

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: A question about classes in C++

Post by chili » October 7th, 2017, 8:53 am

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())
Chili

eagerStudent
Posts: 5
Joined: October 7th, 2017, 8:32 am

Re: A question about classes in C++

Post by eagerStudent » October 8th, 2017, 5:39 am

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!

Post Reply