Skip to main content
Post Closed as "Not suitable for this site" by dumbass, Toby Speight, Zephyr
deleted 149 characters in body
Source Link
Shreyas
  • 1.9k
  • 18
  • 34

Why are the destructors not called?

Even though I've written destructors for class A and B, it's not being called.


#include<iostream.h> #include<conio.h> class A { public : A() { cout<<"\nIn A const."; } ~A() { cout<<"\nIn A dest."; } }; class B : public A { public : B() { cout<<"\nIn B const."; } ~B() { cout<<"\nIn B dest."; } }; int main() { A a; B b; getch(); return 0; } 

I've given the actual code above. Removing the following statements perfectly shows the calling of destrutors.

int main() { A a; B b; } 

Why isn't constructor getting called?

Why are the destructors not called?

Even though I've written destructors for class A and B, it's not being called.


#include<iostream.h> #include<conio.h> class A { public : A() { cout<<"\nIn A const."; } ~A() { cout<<"\nIn A dest."; } }; class B : public A { public : B() { cout<<"\nIn B const."; } ~B() { cout<<"\nIn B dest."; } }; int main() { A a; B b; getch(); return 0; } 

I've given the actual code above. Removing the following statements perfectly shows the calling of destrutors.

int main() { A a; B b; } 

Why are the destructors not called?

Even though I've written destructors for class A and B, it's not being called.


#include<iostream.h> #include<conio.h> class A { public : A() { cout<<"\nIn A const."; } ~A() { cout<<"\nIn A dest."; } }; class B : public A { public : B() { cout<<"\nIn B const."; } ~B() { cout<<"\nIn B dest."; } }; int main() { A a; B b; getch(); return 0; } 

Why isn't constructor getting called?

added 278 characters in body
Source Link
Shreyas
  • 1.9k
  • 18
  • 34

Why are the destructors not called?

Even though I've written destructors for class A and B, it's not being called.


#include<iostream.h> #include<conio.h> class A { public : A() { cout<<"\nIn A const."; } ~A() { cout<<"\nIn A dest."; } }; class B : public A { public : B() { cout<<"\nIn B const."; } ~B() { cout<<"\nIn B dest."; } };   int main() {  A a; B b; getch(); return 0; } 

I've given the actual code above. Removing the following statements perfectly shows the calling of destrutors.

int main() { A a; B b; } 

Why are the destructors not called?

Even though I've written destructors for class A and B, it's not being called.


class A { public : A() { cout<<"\nIn A const."; } ~A() { cout<<"\nIn A dest."; } }; class B : public A { public : B() { cout<<"\nIn B const."; } ~B() { cout<<"\nIn B dest."; } }; int main() { A a; B b; } 

Why are the destructors not called?

Even though I've written destructors for class A and B, it's not being called.


#include<iostream.h> #include<conio.h> class A { public : A() { cout<<"\nIn A const."; } ~A() { cout<<"\nIn A dest."; } }; class B : public A { public : B() { cout<<"\nIn B const."; } ~B() { cout<<"\nIn B dest."; } };   int main() {  A a; B b; getch(); return 0; } 

I've given the actual code above. Removing the following statements perfectly shows the calling of destrutors.

int main() { A a; B b; } 
Source Link
Shreyas
  • 1.9k
  • 18
  • 34

Destructors not called

Why are the destructors not called?

Even though I've written destructors for class A and B, it's not being called.


class A { public : A() { cout<<"\nIn A const."; } ~A() { cout<<"\nIn A dest."; } }; class B : public A { public : B() { cout<<"\nIn B const."; } ~B() { cout<<"\nIn B dest."; } }; int main() { A a; B b; }