Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What are the OOPS concepts?

Answer Posted / d. prashant

OOPS concepts

Objects
Classes
Inheritance
Data Abstraction
Data Encapsulation
Polymorphism
Overloading
Reusability


In order to understand the basic concepts in C++, the
programmer must have a command of the basic terminology in
object-oriented programming. Below is a brief outline of
the concepts of Object-oriented programming languages:



Objects:
Object is the basic unit of object-oriented programming.
Objects are identified by its unique name. An object
represents a particular instance of a class. There can be
more than one instance of an object. Each instance of an
object can hold its own relevant data.







An Object is a collection of data members and associated
member functions also known as methods.



Classes:
Classes are data types based on which objects are created.
Objects with similar properties and methods are grouped
together to form a Class. Thus a Class represent a set of
individual objects. Characteristics of an object are
represented in a class as Properties. The actions that can
be performed by objects becomes functions of the class and
is referred to as Methods.



For example consider we have a Class of Cars under which
Santro Xing, Alto and WaganR represents individual Objects.
In this context each Car Object will have its own, Model,
Year of Manufacture, Colour, Top Speed, Engine Power etc.,
which form Properties of the Car class and the associated
actions i.e., object functions like Start, Move, Stop form
the Methods of Car Class.



No memory is allocated when a class is created. Memory is
allocated only when an object is created, i.e., when an
instance of a class is created.



Inheritance:
Inheritance is the process of forming a new class from an
existing class or base class. The base class is also known
as parent class or super class, The new class that is
formed is called derived class. Derived class is also known
as a child class or sub class. Inheritance helps in
reducing the overall code size of the program, which is an
important concept in object-oriented programming.



Data Abstraction:
Data Abstraction increases the power of programming
language by creating user defined data types. Data
Abstraction also represents the needed information in the
program without presenting the details.



Data Encapsulation:
Data Encapsulation combines data and functions into a
single unit called Class. When using Data Encapsulation,
data is not accessed directly; it is only accessible
through the functions present inside the class. Data
Encapsulation enables the important concept of data hiding
possible.



Polymorphism:
Polymorphism allows routines to use variables of different
types at different times. An operator or function can be
given different meanings or functions. Polymorphism refers
to a single function or multi-functioning operator
performing in different ways.



Overloading:
Overloading is one type of Polymorphism. It allows an
object to have different meanings, depending on its
context. When an exiting operator or function begins to
operate on new data type, or class, it is understood to be
overloaded.



Reusability:
This term refers to the ability for multiple programmers to
use the same written and debugged existing class of data.
This is a time saving device and adds code efficiency to
the language. Additionally, the programmer can incorporate
new features to the existing class, further developing the
application and allowing users to achieve increased
performance. This time saving feature optimizes code, helps
in gaining secured applications and facilitates easier
maintenance on the application.

The implementation of each of the above object-oriented
programming features for C++ will be highlighted in later
sections.



A sample program to understand the basic structure of C++




Sample Code



//program to read employee details and to output the data



////////// code begins here /////////////////////////////

#include <iostream> // Preprocessor directive

using namespace std;

class employee // Class Declaration

{

private:

char empname[50];

int empno;



public:

void getvalue()

{

cout<<"INPUT Employee Name:";

cin>>empname;

cout<<"INPUT Employee Number:";

cin>>empno;

}



void displayvalue()

{

cout<<"Employee Name:"<<empname<<endl;

cout<<"Employee Number:"<<empno<<endl;

}

};



main()

{

employee e1; // Creation of Object

e1.getvalue();

e1.displayvalue();

}



///// code ends here //////////////

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between data abstraction and encapsulation?

1031


What is difference between abstraction and encapsulation?

1019


What is difference between polymorphism and inheritance?

1019


What is difference between oop and pop?

1102


Can you inherit a private class?

1057


What is oops with example?

996


Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.

2407


What are different oops concepts?

999


What do you mean by variable?

974


What is ambiguity in inheritance?

1050


What is an interface in oop?

982


What is the use of oops?

993


class type to basic type conversion

2337


Which is not an object oriented programming language?

935


This program numbers the lines found in a text file. Write a program that reads text from a file and outputs each line preceded by a line number. Print the line number right-adjusted in a field of 3 spaces. Follow the line number with a colon, then one space, then the text of the line. You should get a character at a time and write code to ignore leading blanks on each line. You may assume that the lines are short enough to fit within a line on the screen. Otherwise, allow default printer or screen output behavior if the line is too long (i.e., wrap or truncate). A somewhat harder version determines the number of spaces needed in the field for the line numbers by counting lines before processing the lines of the file. This version of the program should insert a new line after the last complete word that will fit within a 72-character line.

2079