run time problem in inheritance.



Hi all,

I have a problem. When i am deleting object my programe immediately crash. I
dont know what is the reson behind this.(I think problem is like i am delete
some stack variable.)

#include<iostream>
using namespace std;
class Base {
private:
int i;
public:
Base(){i = 999;}
void show() {
cout<<"value of i is..."<<i<<endl;
}
};
class Der : public Base {
private:
int d;
public:
Der(){d = 100;}
virtual void show() {
cout<<"value of i is..."<<d<<endl;
}
};
int main() {
Base *obj = new Der;
obj->show();
delete obj;
return 0;
}


.



Relevant Pages

  • Re: run time problem in inheritance.
    ... using namespace std; class Base {private: int i; public: ... }}; class Der: public Base {private: int d; public: ... Base *obj = new Der; ...
    (microsoft.public.vc.language)
  • renee.c
    ... typedef struct AttrString *AttrString; ... Tcl_Obj *Obj; ... int red, green, blue, index; Colour next; ... chars name; ...
    (comp.lang.tcl)
  • Re: Double Linked List test
    ... int main ... boolean test(struct Obj *l, char *value_wanted) ... struct Obj *p_link; ...
    (comp.lang.c)
  • Double Linked List test
    ... int main ... boolean test(struct Obj *l, char *value_wanted) ... struct Obj *p_link; ...
    (comp.lang.c)
  • Re: OT: C++ help
    ... virtual void f; ... int main{ ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)