Can a double colon operator(scope resolution operator) be used to define functions other than in classes? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can a double colon operator(scope resolution operator) be used to define functions other than in classes?

(yes/no) Please post the explanation too.

2nd Jul 2017, 2:47 AM
Teja Pothkan
Teja Pothkan - avatar
1 Answer
+ 1
Yes u can use a scope resolution operator to define a class function. Many times it is preffered to do so because of the basic difference it make. When we define the function within the class then its an Inline Function but on the other hand when we define it outside the class using scope resolution, it does not remain Inline anymore. For larger functions its better to not be inline as it makes it slow at runtime. I hope it helps!
3rd Jul 2017, 2:56 PM
Mrinmay Bhattacharyya
Mrinmay Bhattacharyya - avatar