Content of Homework Should Start From This Page Only
Content of Homework Should Start From This Page Only
Declaration:
I declare that this assignment is my individual work. I have not copied from any other student’s work or
from any other source except where due acknowledgment is made explicitly in the text, nor has any part
been written for me by another person.
Student’s Signature : __
____gurbachan singh_
Evaluator’s comments:
_____________________________________________________________________
2. Multilevel Inheritance:
In this type of inheritance, there are number of level and it has used in that cases where we want
to use all properties in number of levels according to there quirement. For example, class A
inherited in class b and class b has inherited inclass c for class b so on. Where class A is base
class c. In another way we can say bis derived class a base class for c and a indirect base class for
c is indirect baseclass for c and c indirect derived class for class A.
3. Multiple Inheritances:
In this type of inheritance, number of classes has inherited in a single class. Wheretwo or more
classes are, know as base class and one is derive class
4. Hierarchical Inheritance:
This type of inheritance helps us to create a baseless for number of classes andthose numbers of classes can
have further their branches of number of class.
5. Hybrid Inheritance:
In this type of inheritance, we can have mixture of number of inheritances but thiscan generate an
error of using same name function from no of classes, which willbother the compiler to how to use the
functions. Therefore, it will generate errors inthe program. This has known as ambiguity or
duplicity.
In our example, we will describe how to implement a linked list in which the data at each node is
a single word (i.e. string of characters). The first task is to define anode. To do this, we can
associate a string with a pointer using a
Structure definition
:
struct Node{char word[MAX_WORD_LENGTH];Node *ptr_to_next_node;};
or alternatively
struct Node;typedef Node *Node_ptr; struct Node{char word[MAX_WORD_LENGTH];Node_ptr
ptr_to_next_node;};
int main()
{
std::vector<Animal*> animals;
animals.push_back(new Animal());
animals.push_back(new Wolf());