c++ - How to access a function from a class? -


how access function class, outside of class?

example:

int main(int argc, char *argv[]) {     class imageloading     {      void loading()     {         cout << 5 <<endl;     }      };  loading();  return 0; } 

a standard function defined in class instance class. can used on instance, i.e. created object. that, need create imageloading class instance:

imageloading instance; instance.loading(); 

it possible create functions associated class , not instances. that, need add keyword static in function definition

static void loading() {     cout << 5 << endl; } 

then use it, need tell static class defined in imageloading. syntax classname::methodname() so:

imageloading::loading(); 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -