IGNOU Latest Assignments
IGNOU BCA Assignments BCA 2009
IGNOU BCA Assignments BCA 2008
IGNOU BCA Assignments BCA 2007
IGNOU BCA Assignments BCA 2006
IGNOU Latest Assignments
IGNOU BCA Assignments IGNOU BCA Assignments
IGNOU BCA Assignments IGNOU MCA Assignments
IGNOU MBA Assignmants IGNOU MBA Assignments

IGNOU > IGNOU Assignments > BCA > BCA 2007 Assignments > C++ and Object Oriented Programming

IGNOU BCA Assignments

Question 2: (a). Describe the terms given below giving one example of each:

  1. Virtual function
  2. Friend function
  3. Multiple inheritance
  4. Copy constructor

Ans:

(a). Friend Function

The member method of any class is only accessible by object of that class i.e. a non member object can’t access member method of class but if we want to communicate or access with member method of two or more classes then we create a common function which is friendly to all the classes. This type of function is created with the keyword “Friend” as prefix with function signature and prototype that function in two or more classes. That means, this function is able to access data element of two or more classes which are friendly to it. The friend function is also known as “Bridge” function. e.g.

Class demo1
{ int a;
public;
demo1()
{ a=10;
}
void display ()
{ cout <<a;
}
friend void average (demo1, demo2).
};
void main ()
{ demo1 ob1;
demo2 ob2 (20);

average (ob1, ob2);
}

* Class demo2
{ int b;
public;
demo2(int x)
{ d=n;
}
void display ()
{ cout <<b;
}
friend void average (demo1, demo2).
};

(c). Multiple Inheritance

Inheritance is the fundamental OOP feature in which inherit the predefined properties creating new derived class. Having some additional attribute. The class which is inherited is known as base class and who inherits is known as derived class.

When a class inherit the properties of more than one class then it is called Multiple Inheritance i.e. a sub class or derived having more than one super or base class. e.g.

class A: public B, public C.
{
=
};

(d). Copy constructor:

When a constructor is use to initialize the data element of one object by data element of other object then that type of constructor is known as copy constructor. e.g.

class ABC
{ int a;
public;
ABC (int x)
{ a = x;
}
ABC (ABC ob) // copy constructor
{ a = ob. A;
}
void display ()
{
cout << a;
}
};
void main ()
{ABC m (10);
ABC n(m);
m.display (); n.display ();
}

PREVIOUSINDEX