Why to use function outside the class using scope resolution operator??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why to use function outside the class using scope resolution operator???

16th Sep 2016, 5:39 PM
abhishek shinde
abhishek shinde - avatar
3 Answers
+ 2
In usual class definitions are in header file and function definition in source file.
16th Sep 2016, 5:58 PM
Geek
Geek - avatar
0
Code reading gets easy as member variables n function declarations in class definition. And function definition outside class.
16th Sep 2016, 5:57 PM
Geek
Geek - avatar
0
ok if your function contain iteration statement like loop then you must defined body of that function outside of class, so scope operator use to tell compiler that this function belongs to that particullar class which is not a inline function, so in execution that part of function must be link with that class using linker.
17th Sep 2016, 2:06 PM
Reyad Hossain
Reyad Hossain - avatar