+ 3
Is it mandatory to define function outside the class?
5 Réponses
+ 1
No. It gets much more complicated. Imagine you need a class for one specific function. You create the class in the function, and then use the class in the function. So you can have 4 objects of this class, but it isn't accessible anywhere else... well... because it exists only in the Function.
+ 1
no
0
generally , if we define a function inside a class its request to compiler to act as inline function ... inline function take less time compiling ... so functions which are smaller sized can be defined inside a class ... otherwise ,function which contain a loop, switch case, etc ... should be declare inside class but defined outside the class ..
0
no it is not necessary to define a function outside a class.
0
No it is a bad idea to define a function outside a class as it creates complexity.