oops record for iii eee1
TRANSCRIPT
-
8/6/2019 Oops Record for III Eee1
1/20
MOHAMED SATHAK A.J. COLLEGE OF ENGINEERING
(Approved by AICTE, New Delhi and Affiliated to Anna University)
34, Old Mahabalipuram Road, Egattur, Chennai 603 103.
Sponsored by:MOHAMED SATHAK TRUST, Chennai 600 034.
CS 2209 OBJECT ORIENTED PROGRAMMING STRUCTURE LAB
NAME :
REGISTER NUMBER :
DEPARTMENT :
YEAR / SEM :
-
8/6/2019 Oops Record for III Eee1
2/20
INDEX
Ex.
NODate EXPERIMENT NAME
Page
NoSignature
1.aDEFAULT ARGUMENTS
1.bSTATIC DATA MEMBER
1.cSTATIC MEMBER FUNCTION
1.dSTUDENT DETAILS
2.MATRIX VECTOR MULTIPLICATION
USING FRIEND FUNCTION
3. COMPLEX NO USING OPERATOROVERLOADING
4.UNARY OPERATOR OVERLOADING
5.TYPE CONVERSION
5aDATA OBJECT TO OBJECT TYPE
5.b STRING OBJECT USINGCONVERSION TYPE
5.cCONVERSION FROM
6.
MATRIX CLASS WITH DYNAMIC
MEMORY ALLOCATION(GIVE
CONSTRUCTOR,DESTRUCTOR,COPY
CONSTRUCTOR,OVERLOADING
ASSIGNMENT OPERATOR)
7. OVERLOAD NEW AND DELETEOPERATOR
8. LINKED LIST USING TEMPLATES
-
8/6/2019 Oops Record for III Eee1
3/20
Ex.
NODate EXPERIMENT NAME
Page
NoSignature
9. BUBBLE SORT USING TEMPLATE
10.INSERTION SORT USING TEMPLATE
11.EXCEPTION HANDLING MECHANISM
12.STACK WITH NECESSARY
EXCEPTION HANDLING
13.HIERARCHY INHERITANCE &DYNAMIC POLYMORPHISM
14. MULTILEVEL INHERITANCE
15.FILE CONCEPT
-
8/6/2019 Oops Record for III Eee1
4/20
MONEY TRANSFER
#include
#include
class AccClass
{
int accno;
float balance;
public:
void getdata()
{
coutaccno;
coutbalance;
}
void setdata(int accin)
{
accno=accin;
balance=0;
}
void setdata(int accin,float balancein)
{
accno=accin;
balance=balancein;
}
void display()
{
cout
-
8/6/2019 Oops Record for III Eee1
5/20
int transmoney;
clrscr();
AccClass acc1,acc2,acc3;
acc1.getdata();
acc2.setdata(10);
acc3.setdata(20,750.5);
cout
-
8/6/2019 Oops Record for III Eee1
6/20
-
8/6/2019 Oops Record for III Eee1
7/20
ARITHMETIC OPERATIONS
#include
#include
#include
#include
class arith
{
public:
int a,b,c;
int add,sub,pro;
void getdata(void);
void sum();
void diff();
void mul();
void exit();};
void main()
{
arith p;
int ch;
clrscr();
cout
-
8/6/2019 Oops Record for III Eee1
8/20
}
getch();
}
void arith::getdata(void)
{
couta>>b;
}void arith::sum()
{
int add=a+b;
cout
-
8/6/2019 Oops Record for III Eee1
9/20
COMPLEX NUMBERS USING COSTRUCTOR OVERLOADING
#include
#include-+
*96
+/8520
+/85200
class complex
{
float x,y;
public:
complex()
{
}
complex(float a){
x=y=a;
}
0 complex(float real,float imag)
x=real;
y=imag;
}
friend complex sum(complex,complex);
friend void show(complex);
};
complex sum(complex c1,complex c2)
{
complex c3;
c3.x=c1.x+c2.x;
c3.y=c1.y+c2.y;
return(c3);
}
void show(complex c)
{cout
-
8/6/2019 Oops Record for III Eee1
10/20
C=sum(A,B);
cout
-
8/6/2019 Oops Record for III Eee1
11/20
coutfeet;
coutinches;
}
void show()
{
cout
-
8/6/2019 Oops Record for III Eee1
12/20
D2=11-6.25
D3=D1+D2=17-16.5
BINARY OVERLOADING
#include
#include
class bin
{
private:
int a,b;
public:
bin()
{
a=0;
}
void read(){
cin>>a;
}
void print()
{
cout
-
8/6/2019 Oops Record for III Eee1
13/20
b1.print();
b1-=b2;
cout
-
8/6/2019 Oops Record for III Eee1
14/20
cout
-
8/6/2019 Oops Record for III Eee1
15/20
5005
Enter the Sex:
Male
Enter the Height:
175
Enter the weight:
80
Name: Hassan
Roll No: 5005
Sex : Male
Height : 175
Weight : 80
MULTILEVEL INHERITANCE
#include
#include
class student
{
protected:
int roll_no;
public:
void get_number(int);
void put_number(void);
};
void student::get_number(int a)
{
roll_no=a;
}
void student::put_number()
{cout
-
8/6/2019 Oops Record for III Eee1
16/20
void get_marks(float,float);
void put_marks(void);
};
void test::get_marks(float x,float y)
{
sub1=x;
sub2=y;
}void test::put_marks()
{
cout
-
8/6/2019 Oops Record for III Eee1
17/20
UNARY OPERATOR
#include
#include
class index
{
private:
int value;
public:
index()
{
value=50;
}int getindex()
{
return value;
}
void operator++()
{
value=value+1;
}
};
void main()
{
clrscr();
index idx1,idx2;
cout
-
8/6/2019 Oops Record for III Eee1
18/20
Enter the Value of idx1:0
Enter the value of idx2:0
Show the Value of idx1:1
Show the value of idx2:1
FUNCTION OVERLOADING
#include
#include
class fn
{
public:
void volume(int a);
void volume(long l,long b,long h);void volume(double r,int h);
};
void fn::volume(int a)
{
int t;
t=a*a*a;
cout
-
8/6/2019 Oops Record for III Eee1
19/20
obj.volume(4.5,8);
getch();
}
Output
Volume of the cube is : 1000
Volume of the cuboid is :120Volume of the cylinder :508
VIRTUAL FUNCTION
#include
#include
class shape
{protected:
int x,y,a;
public:
void getdata()
{
coutx>>y;
}
virtual void display()=0;
};
class rectangle:public shape
{
public:
void display()
{
cout
-
8/6/2019 Oops Record for III Eee1
20/20
{
coutdisplay();
getch();}
Output
Enter the values of x and y:
5
4
Value of x=5
Value of y=4
Area of rectangle is20
Enter the value of x and y
5
5
Area of triangle is
12.5