0
Where in c++ double colon(::) can be used?
4 Answers
+ 7
It is called the scope resolution operator. It defines the scope of a member function or a variable. The declaration of the member function is generally done within the class. However the description may or may not be given in the class. So to tell the compiler that a particular function belongs to a particular class we use ::
Ex: <return type> <classname>::function name(arguments)
+ 4
it can.be used to use functions of an another namespace that isnt defined on the program.
E.X: you dont need to write using namespace std; you can just write it std::cout<< etc etc etc
+ 1
It may be used to define a member function for a class that's been declared previously. For example you have a class Dog in your header file and it contains the declaration for a member function void fetch();
in your source file you can define it by using the score resolution operator void Dog::fetch(){}
- 3
pata nai