KEMBAR78
C++ Extra Program | PDF | Object Oriented Programming | C++
0% found this document useful (0 votes)
5 views4 pages

C++ Extra Program

Uploaded by

mspvlit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

C++ Extra Program

Uploaded by

mspvlit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

OOP Concepts:

The object oriented paradigm is built on the foundation laid by the structured programming
concepts. The fundamental change in OOP is that a program is designed around the data being
operated upon rather upon the operations themselves. Data and its functions are encapsulated into
a single entity.OOP facilitates creating reusable code that can eventually save a lot of work. A feature
called polymorphism permits to create multiple definitions for operators and functions. Another
feature called inheritance permits to derive new classes from old ones. OOP introduces many new
ideas and involves a different approach to programming than the procedural Programming.

Benefits of object oriented programming:

• Data security is enforced.

• Inheritance saves time.

• User defined data types can be easily constructed.

• Inheritance emphasizes inventions of new data types.

• Large complexity in the software development cn be easily managed.

Basic C++ Knowledge:

C++ began its life in Bell Labs, where Bjarne Stroustrup developed the language in the early
1980s. C++ is a powerful and flexible programming language. Thus, with minor exceptions, C++ is a
superset of the C Programming language. The principal enhancement being the object –oriented
concept of a class.

A Class is a user defined type that encapsulates many important mechanisms. Classes enable
programmers to break an application up into small, manageable pieces, or objects.

LAB OBJECTIVE

Upon successful completion of this Lab the student will be able to:

1. You will be able to know about Object oriented programming.

2. Use Abstract Data Types in the programs.

3. Application of Non recursive functions.

4. OOP principles like Encapsulation Inheritance Polymorphism were frequently used.

EXTRA PROGRAMS
4. Write a Program to Demonstrate the Catching of All Exceptions.

Aim: To Write a Program to Demonstrate the Catching of All Exceptions.

Source Code:

#include<iostream.h>

#include<conio.h>

void test(int x)

try

if(x>0)

throw x;

else

throw 'x';

catch(int x)

cout<<"Catch a integer and that integer is:"<<x;

Catch (char x)

Cout<<”catch a character and that character is:"<<x;

Void main()

Clrscr();

Cout<<”Testing multiple catches\n:";

test(10);

test(0);
getch();

Output:

Testing multiple catches Catch a integer and that integer is: 10

Catch a character and that character is: x

2. Write a Template Based Program to Sort the Given List of Elements.

Aim: To Write a Template Based Program to Sort the Given List of Elements.

Source Code:

#include using namespace std;

template void bubble(T a[], int n)

int i, j;

for(i=0;ia[j+1])

T temp;

temp = a[j];

a[j] = a[j+1];

a[j+1] = temp;

int main()

int a[6]={17,16,15,14,9,-1};

char b[4]={'z','b','x','a'};

bubble(a,6);
cout<<"\nSorted Order Integers: ";

for(int i=0;i<<a[i]<<"\t";

bubble(b,4);

cout<<"\nSorted Order Characters: ";

for(int j=0;j<<b[j]<<"\t"; }

Output:

Sorted Order Integers: -1 9 14 15 16 17

Sorted Order Characters: a b x z

You might also like