+ 1
What is difference explicit and implicit call of a function?
4 Réponses
+ 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
+ 2
thanks for sharing
+ 1
in short which gets automatically processed due to compiler is implicit call and which user specifies is explicit
0
Yep! You've got it