C++ :
Lol :D
C++ is a middle-level programming language developed by Bjarne Stroustrup in 1979.
C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.
C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.
Access Specifier - public, private , protected
- Encapsulation
-
Data hiding
-
Inheritance
-
Polymorphism
Data hiding
Inheritance
Polymorphism
ENCAPSULATION:
As the diagram below shows, Encapsulation hides the implementation away from the user (in this case a lion) who can do all its operations without seeing how it does it. Also think of a car, we now how to get from destination A to B without knowing how the engine works under the bonnet or seeing it work.
Each class has two parts:
- The Interface is the implementation code for the external Interface i.e. in the diagram the body of the lion.
- The Implementation is the code that does all the operations, makes the interface look as if it is doing something.
DATA HIDING:
In C++, data can be hidden by making it private. Thus Encapsulation is achieved.
INHERITANCE:
One of the most useful aspects of object-oriented programming is code reusability.
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.
It helps to reduce the code size.
Vehicle- Base class. Motorized Vehicle- Intermediate class. Car - Child class
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 to many. That is a single function or an operator functioning in many ways different upon the usage is called polymorphism.
ABSTRACT DATA TYPE
Data abstraction refers to, providing only essential information to the outside world and hiding their background details, i.e., to represent the needed information in program without presenting the details.
Overloading :
When you call an overloaded function or operator, the compiler determines the most appropriate definition to use by comparing the argument types you used to call the function or operator with the parameter types specified in the definitions. The process of selecting the most appropriate overloaded function or operator is called overload resolution.
BASIC SYNTAX:
- Object - Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors - wagging, barking, eating. An object is an instance of a class.
- Class - A class can be defined as a template/blueprint that describes the behaviors/states that object of its type support. Collection of similar objects.
- Methods - A method is basically a behavior. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed.
- Instant Variables - Each object has its unique set of instant variables. An object's state is created by the values assigned to these instant variables.
C++ Program Structure
#include<iostream>
using namespace std;
int main()
{
cout<<"Hello World";
return 0;
}
Access Specifier :
#include<iostream.h>
#include<conio.h>
class Digit
{
public: int a;
private: int b;
protected: int c;
};
void main()
{
clrscr();
Digit d;
d.a=10;
d.c=20;
cout<<d.a;
cout<<d.c;
getch();
}
No comments:
Post a Comment