Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) DestructorExample1

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppDestructorExample1/CppDestructorExample1.pro

 

include(../../ConsoleApplication.pri)

SOURCES += main.cpp

 

 

 

 

 

./CppDestructorExample1/main.cpp

 

#include <iostream>

struct MyClass
{
  ~MyClass() noexcept { std::cout << "Destructor\n"; }
};

int main()
{
  const MyClass m;
} //MyClass destructor called at end of main

/* Screen output:

Destructor
Press <RETURN> to close this window...

*/

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml