C Programming - Short Notes
C++ Programming - Short Notes
1. Introduction to C++:
C++ is an object-oriented programming language developed by Bjarne Stroustrup. It is an extension of the C
language.
2. Basic Structure of a C++ Program:
#include <iostream>
using namespace std;
int main() {
// Code
return 0;
3. Data Types in C++:
- int, float, char, double, bool
- string (from the C++ Standard Library)
4. Variables and Constants:
Variables store data; constants are fixed values.
Example: const int a = 10;
5. Operators in C++:
- Arithmetic: +, -, *, /, %
- Relational: ==, !=, >, <
- Logical: &&, ||, !
6. Control Statements:
C Programming - Short Notes
- if, if-else, nested if
- switch statement
7. Loops in C++:
- for loop
- while loop
- do-while loop
8. Functions in C++:
Functions allow modular programming and code reuse.
Example:
int add(int a, int b) {
return a + b;
9. Object-Oriented Programming (OOP) Concepts:
- Class and Object
- Encapsulation
- Inheritance
- Polymorphism
- Abstraction
10. Classes and Objects:
class Student {
public:
int id;
void display() {
cout << "ID: " << id << endl;
};
C Programming - Short Notes
11. Constructors and Destructors:
- Constructor: Initializes object
- Destructor: Cleans up resources
12. Inheritance:
Allows one class to inherit properties from another.
class A { };
class B : public A { };
13. File Handling in C++:
Used to read/write files using ifstream, ofstream, fstream.
14. Advantages of C++:
- OOP support
- Code reusability
- Closer to hardware (like C)
- Fast and efficient