What is OOPS Using C++ ?
It is a High Level Object Oriented Programming Language Developed by Bizarne Strostrup in 1972 at Bell Laboratories in ATNT of USA.
We will Learn Object Oriented Programming using C++ step by step.Students learning
this language can read this page carefully to learn this language.
Lets Start with Basics which we should in order to Learn any programming Langauge :
What is High Level Language?
High Level Language consists of 0-9 numbers, A-Z charactors and Special Characters.
What is Data Type?
It refers to the type of data and associated operations used to handle the Data.
for example : int,float,structure,constructure etc.
There are Two Types of Data Types :
1. Primitive Data Types : These are the datatypes which are pre defined.We can also say Built-in Data types.
Lets learn what are the Primitive datatypes used in Oops using C++
- Int : Contains integer type of elements and size of int in c++ is 2 bytes
- Long : Contains integer type of elements but size differs.The size of long in c++ is 4 bytes which is the main difference between int and long.
- Float : Contains Integer Decimal Values and size in c++ is 4 bytes.
- Double : Contains Integer Decimal Values and size in c++ is 8 bytes.
- Char : Stores Character variable and size is 1 byte.
2. Non Primitive Data Types : These are the datatypes which user have to create to implement simplicity in program.
for example : Arrays,Classes,Structures etc
By Using these Data Types user can reduce coding of a long program to an extent.
What are Variables?
Variables works as Container to store data elements of specific data type.
It acts as a container of elements or contains value of other elements in it.
To use Variables we need to know Variable Naming Convention :
1.We can use only A to Z , 0 to 9 , _ _ .
2.Beginning of Variable should start from A to Z or _ .
3.Keywords are not allowed.(Keywords are the Special words which have a preserved meaning for ex: class is a keyword)
4.Meaningful and Friendly names should be choosen.
Always remember this variable naming convention before declaring any variable
Lets move further ..
What is Function?
Function refers to the sub-program which can perform a specific task.
Two types of functions are there in C++ :
1. Built – in Functions (Library Functions)
2. User Defined Functions
> Different functions in C/C++ are categorised in a separate header files.
Some of the header files and their Functions are given below :
- cout – Used to display text on Screen
- cin – Used to take input from User
- getch() – Used to get A single charactor from the user and in C language,It is also used to terminate the functioning of the program to echo on the screen but it is not basic function of getch().
- clrscr() – Used to Clear the screen(specially used in previous versions of Turbo C)
5. <ctype.h> (works on character)
These are the some most commonly used header files.When we write any program in C/C++ then firstly we need to declare header file and By declaring header file we can use their functions in the program.
Lets discuss how to declare header file before writing any program in C/C++ :
* Why we use #include?
we use #include because it is a preprocessor directive and used to import header files and without preprocessor directive we cannot import any header file so it is necessary to declare #include and after that bracket and then name of header file.
Functions are pre-categorized in a separate file called header file.
Now,We have learned how to declare header file and header files contains functions.
Format of Writing A Function :
return type functionname()