A
Alexander Pandit
here's the code :
using namespace std;
class A {
public:
A(int j): i(j) {
cout << "constructing an A object :" << i << endl;
}
~A() {
cout << "destructing an A object " << i << endl;
}
void show() {
cout << i << endl;
}
private:
int i;
};
int main() {
A *a;
a->show(); // <--- shouldn't this give a compile error , or does this
result in undefined behaviour?
return 0;
}
using namespace std;
class A {
public:
A(int j): i(j) {
cout << "constructing an A object :" << i << endl;
}
~A() {
cout << "destructing an A object " << i << endl;
}
void show() {
cout << i << endl;
}
private:
int i;
};
int main() {
A *a;
a->show(); // <--- shouldn't this give a compile error , or does this
result in undefined behaviour?
return 0;
}