You are on page 1of 3

WAP to implement function Overloading

using namespace std;

#include<iostream>

class A

public :

void perimeter(int r)

float p;

p=2*3.14*r;

cout<<"perimeter of circle is "<<p;

cout<<endl;

void perimeter(int l,int b) //implementing function overloading

int p=2*(l+b);

cout<<"perimeter of rectangle is :"<<p; cout<<endl;

};

int main()

A obj;

obj.perimeter(7);

obj.perimeter(5,6);

return 0;}
WAP to implement function Overriding

#include<iostream>

#include<stdio.h>

#include<iomanip>

using namespace std;

class CAR

public:

void displaydata()

cout<<"price of car is Rs 5,00,000"<<endl;

cout<<"colour of car is red "<<endl;

cout<<"generate horse power = 330 hp "<<endl;

cout<<"petrol type "<<endl;

};

class SPORTSCAR:public CAR

public:

void displaydata()

cout<<"price of sports car is Rs 70,00,000"<<endl;

cout<<"colour of sports car is white "<<endl;

cout<<"generate horse power = 710 hp "<<endl;

cout<<"petrol type "<<endl;

cout<<"sports car has a fire alarm system"<<endl;


}

};

int main()

SPORTSCAR obj;

obj.displaydata();

You might also like