Where in c++ double colon(::) can be used? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Where in c++ double colon(::) can be used?

20th Jul 2016, 4:55 AM
alex
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)
20th Jul 2016, 8:48 AM
chaitanya guruprasad
chaitanya guruprasad - avatar
+ 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
20th Jul 2016, 4:03 PM
Orfeo Terkuci
Orfeo Terkuci - avatar
+ 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(){}
22nd Jul 2016, 5:47 PM
Kaizen
Kaizen - avatar
- 3
pata nai
23rd Aug 2016, 3:34 AM
mohsin42