0
What does mean by explicitly and implicitly called? In constructor and destructor. When does implicitly get called?
3 Answers
+ 1
I am not sure about constructors but destructors only called implicitly. You cannot call destructor in your code, it is called when program exits.
0
Destructor will be called for stack objects as soon as the end of it's scope is reached. For heap objects you created via "new" you should call delete later. This will trigger the destructor here.
0
implicitly is something u directly use without sending as an argument in a function.. for eg
class A{
int x;
public:
void readx(int y)
{ x=y;. // here you are directly accessing the private member.
}
int random(A z){
A p;
p.x=x+z.x;}// here z is an object passed explicitly
};
void main()
{
A a,b;
a.random(b)}