+ 1

What is difference explicit and implicit call of a function?

30th Jul 2017, 3:46 AM
Komal Laghate
4 Answers
+ 2
You've finished the C++ course so you should know what is a constructor and how operators work so you can understand the difference between implicit and explicit calls. class explaination{ public : explaination (){a=5;}//constructor private: int a; }; int main (){ explaination A;//implicit call, the constructor is called even if you don't write A.explaination(); } This was the first exemple. A second exemple more difficult... class point{ public: point(int x, int y): x(x), y(y){};//constructor point& operator+=(const point& u){ x+=u.x; y+=u.y; return *(this) }//this is an operator overloading private : int x; int y; }; int main (){ point a(2, 3); point b(5, 6); a+=b;//just like a.operator+=(b); it is again an implicit call } The second exemple is difficult, ask if you don't understand
9th Aug 2017, 1:07 PM
Jojo
+ 2
thanks for sharing
9th Aug 2017, 1:18 PM
Komal Laghate
+ 1
in short which gets automatically processed due to compiler is implicit call and which user specifies is explicit
9th Aug 2017, 1:22 PM
Komal Laghate
0
Yep! You've got it
9th Aug 2017, 5:08 PM
Jojo