/  11
C Sharp Tutorial
C# Tutorials
Objects:
This is the basic unit of object oriented programming. That is both data and function that
operate on data are bundled as a unit called as object.
Classes:

The concept of class is similar to the concept of structure in C. In other words classes are
the data types on which objects are created. So while a class is created no memory is
allocated only when an object is created memory gets allocated.

Inheritance:

As the name suggests Inheritance is the process of forming a new class from an existing
class that is from the existing class called as base class, new class is formed called as
derived class. This is a very important concept of object oriented programming since this
feature helps to reduce the code size.

Data Abstraction:

By this feature of object oriented programming it is possible to represent the needed
information in program without presenting the details. Also by the feature of data
abstraction it is possible to create user defined data types and thus increase the power of
programming language.

Data Encapsulation:

Data Encapsulation is the process of combining data and functions into a single unit
called class. By this method one cannot access the data directly. Data is accessible only
through the functions present inside the class. Thus Data Encapsulation gave rise to the
important concept of data hiding.

Polymorphism:

The ability to use an operator or function in different ways in other words giving different
meaning or functions to the operators or functions is called polymorphism. Poly refers
many. That is a single function or an operator functioning in many ways different upon
the usage is called polymorphism.

What is an Object?

An object is a software bundle of related state and behavior.
Software objects are often used to model the real-world objects that you find in everyday
life. Real-world objects share two characteristics: They all have state and behavior.

Dogs have state (name, color, breed, hungry) and behavior (barking, fetching, wagging
tail).
SUNSAT The Perfect Team
C Sharp Tutorial

Software objects are conceptually similar to real-world objects:
they too consist of state and related behavior.
An object stores its state in fields (variables in some programming languages)
and exposes its behavior through methods (functions in some programming languages).

Methods operate on an object’s internal state and serve as the primary mechanism for
object-to-object communication.
Hiding internal state and requiring all interaction to be performed through an object’s
methods is known as
data encapsulation — a fundamental principle of object-oriented programming
What Is a Class?
A class is a blueprint or prototype from which objects are created.
What Is Inheritance?
Inheritance provides a powerful and natural mechanism for organizing and structuring
your software.
What Is an Interface?

An interface is a contract between a class and the outside world.
When a class implements an interface, it promises to provide the behavior published by
that interface.

What Is a Package?
A package is a namespace for organizing classes and interfaces in a logical manner.
Placing your code into packages makes large software projects easier to manage.
Overloading:
The concept of overloading is also a branch of polymorphism. When the exiting operator
or function is made to operate on new data type it is said to be overloaded.
Reusability:

That is object oriented programming has the feature of allowing an existing class which is written and debugged to be used by other programmers and there by provides a great time saving and also code efficiency to the language. Also it is possible to a have the existing class and adds new features to the existing class as pet the programmer’s choice.

Thus the object oriented programming features helps the program ad there by users of the application to achieve increased performance, it saves time of developing the application, give optimized code for the application, helps in gaining secured applications and there by helps in easier maintenance.

We will learn how to implement each of these feature of object oriented programming in
C++ later in later sections.
SUNSAT The Perfect Team
C Sharp Tutorial
Basic Structure:
To start with the programming language C++ let us see how a have an overlook of basic
structure of C++ program.
Let us see a sample program to have an understanding of the basic structure of C++

//program to read employee details and to output the data Comment
#include < iostream.h > Preprocessor Statement
class employee Class Declaration
{private:

char empname[50];
int empno;

public:
void getvalue()
{cout< < ”INPUT EMP NAME:”;

cint > >empname;
cout< < ”INPUT EMP NO:”;
cint > >empno;
}void displayvalue()

{cout< < ”EMP NAME:”< < empname;
coout< < EMP NO:”< < empno;

}
};
main()
{employee e1; Creation of Object

e1.getvalue();
e1.displayvalu();
}Though the later section would explain each section in detail let us see overlook of the
structure of the above program.
Class:

A class in C++ is an encapsulation of data members and functions that manipulate the data. The class can also have some other important members which are architecturally important.

This C++ Tutorial discusses the components of a C++ class. More C++ tutorials will
follow.
C++ Tutorial - Class Data Members:
SUNSAT The Perfect Team

Share & Embed

More from this user

Add a Comment

Characters: ...