C++ Destructor Exception -


i novice programmer working on code school. when following code executed, word bad output. not understand why letter c in destructor not output when writelettersobj object terminated.

// lab 1  // #include "stdafx.h" #include <iostream> #include <conio.h> using namespace std;  class writeletters { public:     writeletters();     void writeoneletter();     ~writeletters(); } writelettersobj;  writeletters::writeletters() {     cout << "b"; }  void writeletters::writeoneletter() {     cout << "a"; }  writeletters::~writeletters() {     cout << "c" << endl; }  int main() {     writelettersobj.writeoneletter();     cout << "d";     getch();      return 0; } 

you mixing iostream non-ansi conio.h.

make change:

// getch(); cin.get(); 

hey presto, c appears. @ least on os x does. , ubuntu.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -