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

Cursor error with postgresql, pgpool and php -

delphi - ESC/P programming! -

c++ - error: use of deleted function -