Object Oriented Programming
Introduction
OOP (Object-Oriented Programming) is a programming style where you organize code using objects instead of just functions and logic.
Think of it like real life. Everything is an object, like a car, student, or phone. Each object has:
- Properties (data) → what it has
- Methods (functions) → what it can do
There are many high-level languages that use Object-Oriented Programming. It is a type of programming feature. Mainly there are two types of programming:
- Object-Oriented Programming
- Procedural Programming
Procedural programming language, which was used in C language, is an older approach. Now we use OOP because it provides better structure and flexibility.
OOP vs Procedural Programming
| OOP (Object-Oriented) | Procedural |
|---|---|
| Works with objects (things) | Works with steps (instructions) |
| Focus on data + functions together | Focus on functions only |
| Uses classes and objects | Uses functions and procedures |
| More secure (data hiding) | Less secure |
| Best for big/complex programs | Best for small/simple programs |
C++ Language
C++ language is a high-level language. It is the upgraded version of C language. C++ is a general-purpose programming language that supports both procedural and object-oriented programming.
How to Write in C++
To write code in C++, we require an environment called an Integrated Development Environment (IDE). It is software used to write code.
Integrated Development Environment (IDE)
IDE (Integrated Development Environment) is software used to write, run, and debug code in one place.
Now to write a high-level language (C++) code, we require an IDE software. There is an IDE software called Dev-C++, specially made for beginners.
Dev-C++
Dev-C++ is a free IDE (Integrated Development Environment) used to write, compile, and run C and C++ programs.
Steps to Download Dev-C++
Follow these simple steps:
Step 1: Open browser
Open Google Chrome or any browser.
Step 2: Search
Type: “Download Dev-C++ latest version”
Step 3: Open official or safe website
Click a trusted site like SourceForge.
Step 4: Download file
Click Download. The file will start downloading (.exe file).
Step 5: Open setup
Go to the Downloads folder and double-click the Dev-C++ setup file.
Step 6: Install
Click Next, agree to terms, choose location, and click Install.
Step 7: Finish
Click Finish and open Dev-C++.
Step 8: First run
Select language and choose theme if needed.
How to Start Programming in Dev-C++
Follow these simple beginner steps:
Step 1: Open Dev-C++
Launch Dev-C++ from your desktop or start menu.
Step 2: Create new program
Click File → New → Source File. A blank screen will open.
Step 3: Write your first program
Step 4: Save the file
Click File → Save As and name it hello.cpp.
Step 5: Compile and run
Press F11 or click Execute → Compile & Run.
Step 6: See output
A window will open showing:
Hello World
This is my first program
Function Used in C++
A function in C++ is a block of code that performs a specific task.
Why We Use Functions
- Avoid repeating code
- Make program clean and organized
- Easy to understand
List of Functions in C++
Here is a basic list of commonly used functions in C++:
- Main function
main() → Starting point of program - Input / Output functions
cout → Display output
cin → Take input
endl → New line - String functions
strlen() → Length of string
strcpy() → Copy string
strcmp() → Compare strings - Math functions
sqrt() → Square root
pow() → Power
abs() → Absolute value - Character functions
toupper() → Convert to uppercase
tolower() → Convert to lowercase - User-defined functions
void functionName() → Custom function
C++ Program Syntax
Syntax means the rules for writing a correct C++ program.
Basic Structure of a C++ Program
Explanation
- #include <iostream>
Used to include input/output library - using namespace std;
Allows use of cout and cin - int main()
Main function where program starts - { }
Defines the block of code - cout << "Hello";
Displays output - return 0;
Ends the program
Important Syntax Rules
- Every statement ends with ;
- C++ is case-sensitive
- Use { } for blocks
- Proper spelling is important
Frequently Asked Questions (FAQ)
1. What is C++ programming language?
C++ is a powerful and widely used programming language for developing software, games, and system applications. It supports both procedural and object-oriented programming.
2. What is the use of C++?
C++ is used for game development, software development, operating systems, and embedded systems.
3. Is C++ easy for beginners?
Yes, C++ is beginner-friendly if you start with basic concepts like variables, loops, and functions.
4. What is OOP in C++?
OOP is a method of programming using classes and objects to organize code.
5. What is the main function in C++?
main() is the starting point of every C++ program.
6. What is an IDE for C++?
An IDE is software used to write, compile, and run programs, such as Visual Studio Code.

.png)
.png)
.png)
.png)
.png)
.png)