"test when c++ destructor is called" Code Answer's

You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "test when c++ destructor is called" answered properly. Developers are finding an appropriate answer about test when c++ destructor is called related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like test when c++ destructor is called. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on test when c++ destructor is called. 

test when c++ destructor is called

By Bored BeeBored Bee on May 30, 2021
// order_of_destruction.cpp
#include <cstdio>

struct A1      { virtual ~A1() { printf("A1 dtor\n"); } };
struct A2 : A1 { virtual ~A2() { printf("A2 dtor\n"); } };
struct A3 : A2 { virtual ~A3() { printf("A3 dtor\n"); } };

struct B1      { ~B1() { printf("B1 dtor\n"); } };
struct B2 : B1 { ~B2() { printf("B2 dtor\n"); } };
struct B3 : B2 { ~B3() { printf("B3 dtor\n"); } };

int main() {
   A1 * a = new A3;
   delete a;
   printf("\n");

   B1 * b = new B3;
   delete b;
   printf("\n");

   B3 * b2 = new B3;
   delete b2;
}

Output: A3 dtor
A2 dtor
A1 dtor

B1 dtor

B3 dtor
B2 dtor
B1 dtor

Source: docs.microsoft.com

Add Comment

0

All those coders who are working on the C++ based application and are stuck on test when c++ destructor is called can get a collection of related answers to their query. Programmers need to enter their query on test when c++ destructor is called related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about test when c++ destructor is called for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of test when c++ destructor is called while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "test when c++ destructor is called". Visit this developer's friendly online web community, CodeProZone, and get your queries like test when c++ destructor is called resolved professionally and stay updated to the latest C++ updates. 

C++ answers related to "test when c++ destructor is called"

View All C++ queries

C++ queries related to "test when c++ destructor is called"

Browse Other Code Languages

CodeProZone