Inheritence,polymorphism,dynamic memory allocation

Hey guys...we just started on inheritence,polymorphism and dynamic memory allocation and i'm really confused don't know what's really going on there. will really appreciate some guidence and help. thank you!!
I won't try and explain because there's a lot to explain and doubt I'd be very clear. However, have you looked at the appropriate tutorials on this site?

Here's the contents page http://cplusplus.com/doc/tutorial/.
There's a section called "Object Oriented Programming" of which subsections will describe polymorphism and so forth.
As for dynamic memory allocation there's a page on that too http://cplusplus.com/doc/tutorial/dynamic/.

Hope this helps :)
Ok ... I will help you understand the concept. But I cannot spoon feed it. You have to think it out yourselves. We start with a simple example of inheritance:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class C
// C is a simple class.
// It has 3 variables x, y and z.
{
	public:
	int a, b, c;
};

class D : public C
// This is how inheritance is declared.
// It mean D has everything what C has.
// Plus D has something more which is
// defined below.
{
	public:
	int x, y, z;
};

int main (void)
{
	D d;
	d.x = 10;
	// Anyway 'x' belong to 'd'

	d.a = 100;
	// 'a' does not appear in the definition of D.
	// Instead it is inherited from C.
}


This much should be all right to begin with. The real question is why do you need such feature? Try to answer this yourselves. Don't read any book to begin with. Use only logical thinking.
Topic archived. No new replies allowed.