inheritance question

Hi,
I have two classes, one parent and one child,child is derived from the parent.
They both have a function called "disp()".In child I must use parent::disp() to call this function for parent but accidentally I used disp() alone and nothing happened,program terminates without showing anything.Should I expect that function calling itself over and over?Or is there a built-in mechanism to avoid that? [using dev-c++]


class parent
{
.....
public:
void disp(){..}
};

class child
{
....
public :
void disp()
{
disp(); // this is meant to be parent::disp()
// accidentally I used this instead of parent::disp()
cout<<"this is my own data";
}
};


int main()
{
child c1;
//set object's private data using get() member function
c1.disp();
return 0;
}
You should get a stack overflow / segmentation fault at runtime. Try to put something after calling c1.disp() and see if that is executed.

BTW, on using Dev-C++: http://www.cplusplus.com/forum/articles/36896/
And, please use format tags: http://www.cplusplus.com/articles/firedraco1/
Thanks Bazzy,

I will try to use format tags from now on.

By the way,I read the first link you posted.Since I'm using Dev-C++ for long time (I used it for studying C , too) it will be hard migrating to a new IDE. BTW, Which IDE would you suggest to a newbie of C++ ?
I personally use Code::Blocks, it's simple but has many features and it's very customizable.
This article describes a few IDEs http://www.cplusplus.com/forum/articles/7263/
It may be hard but it's better to learn how to use a good tool rather than keep on using a bad one.
Thanks.

I have just downloaded wxDev-C++ (given on first link you posted).I will also download CodeBlocks and then decide on one of them,after reading about them.
Topic archived. No new replies allowed.