Download as pdf or txt
Download as pdf or txt
You are on page 1of 57

BHILAI INSTITUTE OF TECHNOLOGY,

RAIPUT (C.G.)
SRGI

Department of Computer Science & Engineering


B.Tech - 3rd sem

Name of Subject: Principle of Programming Language(PPL)

Paper No: 2

Lecture No.: Unit 05: L 1

Topic: Fundamentals of C++ Programming

Name of Faculty: Dr. Ashish Kumar Tamrakar

Page| 1
Contents
SRGI

• Friend Function
• Constructor
• Destructor
• Copy Constructor
• Inline Function in C++
• Function Overloading

Page| 2
Friend Function
SRGI

• If a function is defined as a friend function in C++, then the protected and


private data of a class can be accessed using the function..
• They are declared using “ friend “ keyword.
• For accessing the data, the declaration of a friend function should be done inside
the body of a class starting with the keyword friend. They can be invoked as
ordinary functions, with out using any object.
• They can be defined outside the Class, here also they are defined like ordinary
functions and Not like member functions.
– The access specifiers does not effect the visibility of Friend Functions.
– Usually a friend function receives the object as arguments.
Syntax :- friend return-type function-name ( input-arguments ) ;
• Member function of one class can be defined as friend function of another class.
In such case they are defined using scope resolution operator as shown below.

Page| 3
Friend Function
SRGI

Example:
#include<iostream.h> void main()
#include<conio.h> { clrscr();
class sample sample s2;
s2.get();
{ int a,b;
swap(s2); //function call
public:void get() swap(s2) passes the object s2 by
{ cin>>a>>b; } value to the friend function.
friend void swap(sample s); };
void swap( sample s1) getch();
}
{ int temp=s1.a;
s1.a =s1.b;
s1.b = temp;
cout<<”a=”<<s1.a<<”b=”<<s1.b;
}
Page| 4
Friend Class
SRGI

• As we know that a class cannot access the private members of other class.
Similarly a class that doesn’t inherit another class cannot access its protected
members.
• Friend Class: A friend class is a class that can access the private and protected
members of a class in which it is declared as friend. This is needed when we
want to allow a particular class to access the private and protected members of a
class.
• Function Class Example
• In this example we have two classes XYZ and ABC. The XYZ class has two
private data members ch and num, this class declares ABC as friend class. This
means that ABC can access the private members of XYZ, the same has been
demonstrated in the example where the function disp() of ABC class accesses
the private members num and ch. In this example we are passing object as an
argument to the function.

Page| 5
Friend Class Example
SRGI

• #include <iostream>
class XYZ
{ private: char ch='A';
int num = 11;
public:
friend class ABC; };
class ABC
{ public: void disp(XYZ obj)
{ cout<<obj.ch<<endl;
cout<<obj.num<<endl; } }; Output: A
int main() 11
{ ABC obj;
XYZ obj2;
obj.disp(obj2);
return 0; } Page| 6
Constructor
SRGI
• It’s a special function which has the same name as that of the Class name.
• It has No Return-Type, not even void
• It should have public or protected access within the class and rarely declared as
private.
• Constructor overloading is possible. Constructors cannot be virtual.
• It can not be static.
– Default arguments are possible.
– They are invoked automatically as soon as Objects of Class are created.
• We can explicitly call Constructors of a Class.
• It is possible to have more than one constructor in a class.
• They can Not be Inherited.
• If in any Class the Default Constructor is not defined then the compiler calls the
implicit Default Constructor for Initializing objects of the Class.

Page| 7
Constructor
SRGI
There are Three Basic Categories of Constructors.
a. Default Constructor: It takes no parameters and performs no processing
other than reservation of memory. It will always call by the compiler, if no user
defined constructor is being provided.
Syntax :- class-name ( ) { code } ;
b. Parameterized Constructor
Syntax :- class-name ( parameter-list ) { code } ;
c. Copy Constructor.
Syntax :- class-name ( reference of the same class) { code } ;
• Default constructor:
• class sample
• { int a, b;
• public:
• sample()
Page| 8
• { a=0;b=0;
Default Constructor Example
SRGI

Output

Page| 9
Parameterized Constructor Example
SRGI

Output

Page| 10
Destructor
SRGI
• Destructors :-
1. It’s a special function which has the same name as that of the Class name.
2. It has No Input-Arguments and No Return-Type, not even void.
3. Its definition is preceded by Tild symbol “ ~ “.
4. Its called implicitly as soon as the scope for any object finishes. Its invoked for
every object .
5. The compiler creates a Destructor for every Class implicitly by default.
6. If a Destructor is explicitly defined then the compiler will always use the
explicitly defined Destructor.
7. Its generally used to free up the spaces allocated by using “ new “ operator
during calling of Constructors. The de-allocation should be done using “ delete
“ operator
8. The object that is created First is Destructed Last and object created Last is
Destructed First. Syntax :- ~class-name ( ) { code }
Page| 11
Destructor
SRGI
int sample::count;
class sample void main()
{ { clrscr();
static int count; {
int a; sample ob1; //Created First
public: Destructed Last
sample() //Constructor sample ob2; //Created
{ Second Destructed Last
a=++count Second
cout<<"\n"<<" Object number = "<<a<<” is created”; sample ob3; //Created Last
Destructed First
}
} //As scope is finishing so
~sample() //Destructor Destructors would be
{ called
cout<<"\nObject number = "<<a<<”is destroyed”;}}; getch(); }
Page| 12
Copy Constructor
SRGI
• A copy constructor is a special constructor in the C++ programming language
used to create a new object as a copy of an existing object. This constructor takes
a single argument: a reference to the object to be copied.
• Normally the compiler automatically creates a copy constructor for each class
(known as an implicit copy constructor) but for special cases the programmer
creates the copy constructor, known as an explicit copy constructor. In such
cases, the compiler doesn't create one
• There are four instances when a copy constructor is called:
– When an object is returned by value
– When an object is passed (into a function) by value as an argument
– When an object is constructed based on other object (pf same class)
– When compiler generates a temporary object (as in 1 and 2 above; as in explicit
casting, etc...)
• Constructors of a class can be invoked by using existing objects of the class.
Syntax :- obect . class-name :: constructor-function-call ;
Page| 13
Copy Constructor
SRGI
#include <iostream.h> void display( )
#include<conio.h> { cout<<"\nd="<<d<<endl; }};
class code void main( )
{ int d; { clrscr();
public: code A(100); //calls constructor - 2
code() code B(A); //calls copy constructor
{cout<<"\ndefault constructor"; code C=A; //calls copy constructor
} // default constructor code D; //calls no argument constructor
code(int a) //constructor -2 D=A;// It is assignment not initialization
{ d=a; hence no copy const. will be called
cout<<"\nparameterized contrctr"; A.display ( );
} B.display ( );
code(code &x)//copy constructor C.display ( );
{ d=x.d; D.display ( ) ;
cout<<"\ncopy cntrctr"; } getch(); }
Page| 14
Inline Function in C++
SRGI
• Inline functions: - Function execution involves the overhead of jumping to
and from the calling statement. Trading of this overhead in execution time is
considerably large whenever a function is small. Hence in such case inline
functions are used. Inline functions are those whose function body is inserted
in place of the function call statement during the compilations process.
• An inline function definition is similar to an ordinary function, except that the
keyword inline precedes the function definition.
• By default every function created in C++ is Inline.
The syntax for defining an inline function is as follows:
inline function- header ( )
{
Body of the function;
}

Page| 15
Inline Function in C++(Cont..)
SRGI
Ex: inline float getdata (int a, float b)
{ return (a+b);
}
void main ()
{ int a= 35; float b= 18.5;
cout <<“The sum is “<<getdata (a,b);
}
The inline functions are similar to macros in ‘c’ language. But the major
drawback with macros is that the error checking does not occur during
compilation.
The following are the situations where inline functions may not work properly
– Functions returning values, having a loop, a switch or a go to exists
– If the function contains static variables.
– If inline functions are recursive.
Page| 16
Function Overloading
SRGI
• Function overloading:- Function overloading can be defined as define a set
of functions having same name and different signatures. The same function
name will be used with different number of parameters and parameters of
different type. We can use the same function name to create function that
performs a variety of different tasks. This is known as function overloading
(function polymorphism) in OOP.
• The function can perform different operations depending on the argument list
in the function call. At the time of calling correct function to be invoked is
determinates by checking the number and type of the argument but not on the
function return type. For Ex. an overloaded add( ) function handles different
types of data as follows. void max (int a, float b); // prototype 1
void max(int a, int b, int c); // prototype 2
The following function calls can be given in the program:
x= add (5,5.10);//uses prototype 1
y= add (5,6,10);// uses prototype 2
Page| 17
Function Overloading
SRGI

Function overloading Example:-


cin>>l>> b;
#include <iostream.h>
a1= area(l,b);
#include <iomanip.h>
void main()
cout<<“area of the
{ float area (int r); // over loaded function rectangle is
int area (int l, int b); //over loaded function. “<<a1<endl;
float a; float area (int r)
int a1,l,b,r , a1 ; {
cout <<“enter the radius of the circle “<<endl; return (3.141*r*r);
cin>>r; }
a=area(r); int area (int l, int b)
cout << “ area of the circle is “<<a<,endl; {
cout <<“enter the length and breadth of the rectangle”; return (l*b);
} Page| 18
Operator Overloading
SRGI
1. It’s a type of Polymorphism, where we can give additional meaning or
implementation to existing operators. When you overload a unary operator you
have to pass one argument. When you overload a binary operator you have to
pass two arguments. Friend function can access private members of a class
directly.
2. Operator overloading is accomplished by means of special kind of function.
Operator overloading can be carried out by means of either member function or
friend function.
Syntax: return_type operator operator t o be overloaded( parameters);
Eg: void operator ++( ) // same as void increment();
3. Data hiding is a fundamental concept of object-oriented programming. It
restricts the access of private members from outside of the class.
Similarly, protected members can only be accessed by derived classes and are
inaccessible from outside. For example,

Page| 19
Operator Overloading
SRGI
class MyClass
{
private: int member1;
}
int main()
{
MyClass obj;
// Error! Cannot access private members from here.
obj.member1 = 5;
}
However, there is a feature in C++ called friend functions that break this rule
and allow us to access member functions from outside the class.

Page| 20
Operator Overloading
SRGI
• Rules for overloading operators:-
➢ Only those operators that are predefined in the c++ compiler can be overloaded.
New operators cannot be created such as ( $ ,# , @).
➢ Overloaded operator can not take default arguments.
➢ We can’t change the basic meaning of an operator, i.e., we can’t redefine the + to
subtract one value from the other value.
➢ We cannot overload any preprocessor symbol such as #.
➢ We can not change the precedence or grouping of an operator nor we can change
the no of arguments it expects.
➢ Unary operators overloaded by means of a member function take no arguments
and return no values. But unary operators overloaded by means of a friend
functions take one reference argument.
➢ Binary operators overloaded through a member functions take one argument and
those, which are over loaded through a friend function, take 2 arguments.
Page| 21
Operator Overloading
SRGI
• Binary arithmetic operators such as +, -, *, / must explicitly return a value.
• There are some operators that can’t be overloaded (::, *, . , ?:, sizeof().
• Using friend functions to overload >> and << operators.
The general form of overloaded operator member function is as follows
return type class name : : operator op(argument list)
• The assignment operator has some additional restriction. It can be overloaded as
a non-static member function, not as friend function. It is the only operator that
can not be inherited. A derive class can not use a base class assignment operator.
• Operators that cannot be overloaded as friend.
– = operator(assignment operator)
– ( ) operator (function call operator)
– [ ] operator (subscript operator)
– → operator (arrow operator)

Page| 22
Operator Overloading
SRGI
class sample
void main()
{ int x;
{
sample()
sample obj;
{ x=10; }
obj.add(20) //obj+10;
void operator +(int I )
obj.show();
void add( int I)
getch();
{ x=x+I;
}
}
output: 30.
void show( )
{ cout<<x;
}

Page| 23
Operator Overloading
SRGI

Page| 24
Operator Overloading
SRGI
class sample
void main()
{ int x;
{
sample()
sample obj;
{ x=10; }
obj.add(20) //obj+10;
void operator +(int I )
obj.show();
void add( int I)
getch();
{ x=x+I;
}
}
output: 30.
void show( )
{ cout<<x;
}

Page| 25
Operator Overloading( friend function *
SRGI
opr)
void main()
{
sample obj;
obj.add(20) //obj+10;
obj.show();
getch();
}
output: 30.

RCST Rungta College of Science & Technology, Durg, C.G. Page| 26


Operator Overloading( friend function
SRGI
++ opr)

Page| 27
Operator Overloading( friend function
SRGI
++ opr)

Page| 28
Operator Overloading( friend function
SRGI
++ opr)

Page| 29
Inheritance
SRGI
• Inheritance :-
• The mechanism of deriving a new class from an old class is called inheritance or
derivation”
• The old class is referred to as base class and the new one is called the derived
class. The derived class inherits some or all the properties from the base class.
1. It’s a method of implementing reusability of Classes.
2. The Members of one Class can be accumulated in another Class through
Inheritance.
3. The Class which acts as the source of providing its Members for Inheritance is
called the Parent or Base Class. The Class that derives from or acquires the
Members of Base Class is called the Child or Derived Class.
4. The Private members of any Class can Not be Inherited.
5. It adds some enhancement to the base class.

Page| 30
Inheritance
SRGI
• Single Inheritance :- The mechanism of creating a new class from en existing
base class is called single inheritance.
A Base class

B Derived class

• Multiple Inheritance: The mechanism of creating a new class from several base
classes is called multiple inheritance.
A B Base class

C Derived class

Page| 31
Inheritance
SRGI
• Multilevel inheritance: - The mechanism of deriving a class from another
derived class is known as multi level inheritance. The following is an example
A Base class

B Derived class

Derived class from the


C derived class ‘B’

• Hierarchical Inheritance: - The mechanism of deriving more than one derived


class from one base class. This process is known as hierarchical inheritance. The
following is an example.
A Base class

B C D Derived classes

Page| 32
Inheritance
SRGI
• Hybrid inheritance: The mechanism of deriving a class from other derived
classes, which are, derived from the same base class. The following is an
example Grand parent

Parent - 1 Parent - 2

Child

• Defining derived classes: A class that uses inheritance to gain the behavior and
data of another ('base') class is called derived class. A derived class is defined by
specifying its relation ship with the base class in addition to its own details. The
general form of defining a derived class is as follows.
Class derived class_name : visibility-mode base-class-name {
• members of derived class; ----------- };
Page| 33
Inheritance
SRGI
• Public Inheritance :- Here the Child Class acquires the Protected and Public
Members. And they Remain Protected and Public in the Child Class. Its done by
using “public “ keyword during Child Class definition.
• Each public member in the base class is public in the derived class.
• Each protected member in the base class is protected in the derived class.
• Each private member in the base class remains private in the derived class.
• Private Inheritance :- Here the Child Class acquires the Protected and Public
Members. And they Become Private in the Child Class. Its done by using
“private “ keyword during Child Class definition.
• Each public member in the base class is private in the derived class.
• Each protected member in the base class is private in the derived class.
• Each private member in the base class remains private in the derived class and
hence it is visible only in the base class. class base-class name{ };
class child-class-name : private parent-class-name { definition of the child
class}; Page| 34
Inheritance
SRGI
class child-class-name : private parent-class-name { definition of the child
class};
• Protected Inheritance :- Here the Child Class acquires the Protected and Public
Members. And they Become Protected in the Child Class. Its done by using
“protected “ keyword during Child Class definition.
• Each public member in the base class is protected in the derived class.
• Each protected member in the base class is protected in the derived class.
• Each private member in the base class remains private in the derived class
class base-class name{ };
class child-class-name : protected parent-class-name { definition of the child
class};

Page| 35
Single Inheritance Example
SRGI

Page| 36
Multi-Level Inheritance Example
SRGI

Page| 37
Multiple Inheritance Example
SRGI

Page| 38
Inheritance
SRGI
• Accessing private members of base class
class derived : private base
in the derived class by using friend class
: A public member function of a base { public:
class can access the private member of the void show()
derived clas irrespective of the friend class { cout<<”count=”<<++count;
has been derived privately or publicly. //valid
Example: A friend class derived privately. }};
Class base void main()
{ friend class derived; { derived d1;
private: d1.show();
int count; getch();
base( ):count(0) } note: if we derive another
{ } }; class from base and try to access
the private data member count
then there will be an error.
Page| 39
Inheritance
SRGI
• Virtual Base Class: The mechanism of Student

deriving a class from other derived


classes, which are, derived from the same
base class, is called multipath inheritance.
An object of multipath inheritance having
two sets of grand parent class members. Test Sport

They are one from parent -1 and the other


form parent-2. The compiler generates
ambiguity in function call if you try to call
Result
grand parent members using child object.
The duplication of inherited members due
to multiple paths can be avoided by
making the common base class as virtual
base class.

Page| 40
Inheritance
SRGI
class grand parent int a,b;
{ ----------- }; public:
class parent-1:public virtual grand parent void get()
{ ------- }; { cout<<"enter a=";
class parent-2 : virtual public grand parent cin>>a;
{ -----------}; cout<<"enter b=";
cin>>b;}
class child : public parent -1, public parent -2
void show()
{-----------}; {
Example: cout<<"a="<<a<<"\nb="<<b;}
#include<iostream.h>
#include<conio.h> };
class d1 :virtual public base
class base
{ protected :int c;
{ protected: public:
Page| 41
Inheritance
SRGI
public: class child : public d1,public d2
void get1(){cout<<"enter c="; { int e;
cin>>c;} public:
void show1() void get3(){cout<<"enter e=";
cin>>e;}
{ cout<<"\nc="<<c; } };
void show3()
class d2 :virtual public base { cout<<"\ne="<<e; } };
{ protected:int d; void main()
public: { clrscr();
void get2(){cout<<"enter d="; child c1;
c1.get(); c1.show();
cin>>d;}
c1.get1(); c1.show1();
void show2() c1.get2(); c1.show2();
{ cout<<"\nd="<<d; } }; c1.get3(); c1.show3();
getch();
}
Page| 42
Constructors during Inheritance
SRGI
• When Inheritance takes place, an unnamed Instance of the Parent Class gets
created in the every Object created from the Child Class.
• As an Instance of the Parent Class is created, so the constructor of the Parent
Class also gets invoked.
• If there is a Default Constructor in the Parent Class then it gets invoked First and
then the Child Class constructor is invoked.
• If any base class contains a constructor with one or more arguments, then it is
compulsorily to have a constructor in the derived class otherwise it is optional to
specify the constructors in the derived class. When the program execute first it
execute base class constructor and then the derived class constructor.
• Only the Immediate Child Class Constructor can call the Immediate Parent Class
Constructor to satisfy the compiler.
Syntax :- child-class-constructor ( arguments if any ) : parent-class-constructor
(parameters) { definition of the child-class-constructor }

Page| 43
Constructors during Inheritance
SRGI
#include<iostream.h> ~B()
#include<conio.h> { cout<< " object of derived class
class A destroyed";}
{ public: };
void main()
A()
{ clrscr();
{ cout<< " i m base class constructor"; } B b;
~A() getch();
{ cout<< " object of base class destroyed";} }
}; output:
i m base class constructor
class B:public A
i m derived class constructor
{ public: object of derived class destroyed.
B() object of base class destroyed
{ cout<<"i m derived class constructor";
} Page| 44
Pointers to object
SRGI
• Pointers to object:
A pointer can point to an object void main()
created by a class. { A a1;
Example: A *p;
Class A ptr=&a1;
{ int a; p->get(); // or (*p).get();
public: indirection operator
void get() p->show() // or (*p).show()
{cin>>a;} }
void show()
{ cout<<a;}
};

Page| 45
Pointer to Derived Classes
SRGI
Pointer to Derived Classes :-
1. They are declared as pointers along with the class name as the data-type.
2. To access the members of the class arrow symbol “->” is used.
3. Its observed that the pointer of Parent class can point towards the objects of
its Child class. But a Child class pointer cannot point towards Parent class.
4. Its observed that if pointer of Parent class is assigned address of its Child class
then also its cannot access the members of the Child class object, although it can
access the Parent class members, in such situation we can access only those
members which are inherited from the base class and not the members that
originally belong to derived class.

Page| 46
Pointer to Derived Classes
SRGI
main()
class Base
{
{ clrscr();
public: Base b1;
void show() Derive d1;
{ cout<<"\i m base class function"; } }; Base *bp;
bp=&b1;
class Derive: public Base
bp->show(); //This Calls Class Base show()
{ int x; bp=&d1;
public: bp->show();//This also calls Class Base show()
void show() Not Class B show()
bp->get();//error , get is not the member of Base
{ cout<<"\ni m derive class function"; }
bp->show1(); //error
void get() ((Derive*) bp)->show(); // cast the
{ cin>>x;} pointer bp to the Derive type.
void show1() //This calls Class derive show() as bp is converted to
Derive* type
{ cout<<"\n x=”<<x;} };
getch(); Page| 47
}
Virtual Functions
SRGI
• Virtual Functions :- Virtual functions are defined using the keyword “virtual”
before function definition. If we desire to call the Child class function using the
pointer of Parent class then :-
➢ In both the classes we have to define the function with same prototype.
➢ In the Parent class we need to use “virtual” keyword during defining the
function. Now when we assign the address of Child class object to the pointer of
the Parent class and using arrow operator we can call the function of the Child
class.
➢ Polymorphism is the ability to refer to objects of different classes.
➢ A single pointer variable may be used to refer (base class pointer) to the objects
of different classes.
➢ A base pointer even made to contain the address of a derived class, but it always
executes (links) the functions in the base class.
➢ By using virtual functions to make the compiler to ignore the type of the pointer
and choose the member function that matches the type of the object.
Page| 48
When we use the same function name in both the base and derived classes the
Virtual Functions
SRGI
• Virtual Functions :- When we use the same function name in both the base and
derived classes the function in base class is declared as virtual C++ determines
which function to use at run time, based on the type of the object pointed to by
the base pointer rather than the type of the pointer
• Rules for declaring virtual function:
– The virtual function must be member of some class.
– It can not be static.
– They are accessed by using object pointer .
– A virtual function can be friend of another class.
– The prototype of the base class version of the virtual function and all the
derived class version must be identical. If the two function with same name
but different prototype , c++ consider them as overloaded function and the
virtual mechanism is ignored.
– We can not have virtual constructor but we can have virtual destructor.
Page| 49
Virtual Functions
SRGI

Page| 50
Virtual Functions
SRGI

Page| 51
Pure Virtual Functions and Abstract
SRGI Classes
• Pure Virtual Functions and Abstract Classes :- Pure virtual function:-The
virtual function having no body and initialized to zero is called pure virtual
functions.. A class containing pure virtual function is called abstract classes or
pure abstract classes. Where as all other classes without pure virtual function
and which are instantiated are called as concrete classes.
• These are the functions that are declared as Virtual at the same time assigned to
Zero value.
• They don’t have any definition, they are only declared and equated to Zero.
• If a Class contains one or more Pure Virtual functions then that Class becomes
Abstract. Objects of Abstract classes can Not be created.
• If we Inherit an Abstract class then we have to Redefine all the Parent class Pure
Virtual functions in the Child class, otherwise the Child class would also become
an Abstract class. Syntax :- virtual function-name ( parameter list ,if any ) = 0:
Overriding is strictly essential.

Page| 52
Pure Virtual Functions and Abstract
SRGI Classes
• Abstract class: is an incomplete class and hence no object of such class can be
created.

• The main objective of an abstract base class is to provide some behavior or


characteristics to the derived classes and to create base pointer required for the
achieving run time polymorphism.
Exmple: /* A pure virtual function is a virtual function with no body */
#include<iostream.h>
#include<conio.h>
Page| 53
Pure Virtual Functions and Abstract
SRGI Classes

Page| 54
Function Overriding
SRGI
• Function overriding: When the same function exists in both the base class and
the derived class, the function in the derived class will be executed. (This is true
of objects of the derived class. Objects of the base class don’t know anything
about the derived class and will always use the base class functions.) We say that
the derived class function overrides the base class function. This is called the
function overriding. This overriding is avoided by virtual function to achieve run
time polymorphism.
Difference between Overloading and Overriding
No Overloading Overriding

1 Relationship between methods available in the Relationship between a super class


same class. method and a subclass method.
2 Does not block inheritance from the super class. Blocks inheritance from the super
class.
3 Separate methods share (overload) the same name. Subclass method replaces
(overrides) the super class method.

Page| 55
Function Overriding
SRGI
Difference between Overloading and Overriding
No Overloading Overriding

1 Relationship between methods available in the same Relationship between a super class
class. method and a subclass method.

2 Does not block inheritance from the super class. Blocks inheritance from the super
class.

3 Separate methods share (overload) the same name. Subclass method replaces (overrides)
the super class method.

4 Different method signatures. Same method signatures.

5 May have different return types. Must have matching return types.

6 May have different declared exceptions. Must have compatible declared


exceptions.

Page| 56
SRGI

BIT-RAIPUR Page| 57

You might also like