Here's a simple and also a very short program in C++ that makes use of Constructors, Operator Overloading (++,--)and Single Inheritance (cause its a simple program as I mentioned it).......
/* C++ Program For Implementation Of Constructors, Operator Overloading and Inheritance */
class index
{
protected:
int count;
public:
index()
{
count = 0;
}
index(int c)
{
count = c;
}
index operator ++()
{
count++;
}
void display()
{
cout< < endl< < "count = "< < count< < endl;
}
};
class index1 : public index
{
public:
void operator --()
{
count--;
}
};
void main()
{
clrscr();
index1 i;
i++;
i++;
i.display();
i--;
i.display();
getch();
}
Saturday, July 21, 2007
Subscribe to:
Post Comments (Atom)
6 comments:
Thank you............
really it helps a lot,and easy to understand...
void main() is incorrect, it's on the FAQ of Bjarne Stroustrup's website.
main() is an integer returning function, it can cause your operating system problems if not.
thnx...really helped me a lot
thank you
thanks.
this is simple and easy to understand
Post a Comment