mercredi 5 août 2015

Global variable prevents the code to show the result


The following code doesn't show anything! I think the problem is to do with X glob(2); because when I remove it, the code works fine. I don't know what is the reason. Would you help me please? The std_lib_facilities_4.h is here

#include "std_lib_facilities_4.h"
using namespace std;

struct X {
    int val;
    void out(const string& s) {cerr << this << "->" << s << ": " << val << endl; }

     X(int v) { val = v; out("X(int)"); }
    ~X() { out("~X()"); }

};

X glob(2); // A global variable

int main()
{
    X loc(4);

    char ch;
    cin>>ch;
    return 0;
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire