KEMBAR78
C++ OOPs Concepts Notes | PDF
0% found this document useful (0 votes)
8 views2 pages

C++ OOPs Concepts Notes

The document discusses key concepts in C++ including function overloading, polymorphism, and the differences between function overloading and overriding. It also covers friend functions, pointers, streams, and file I/O operations, providing examples and highlighting advantages and disadvantages. Overall, it serves as a concise guide to important C++ programming features.

Uploaded by

traderu61
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

C++ OOPs Concepts Notes

The document discusses key concepts in C++ including function overloading, polymorphism, and the differences between function overloading and overriding. It also covers friend functions, pointers, streams, and file I/O operations, providing examples and highlighting advantages and disadvantages. Overall, it serves as a concise guide to important C++ programming features.

Uploaded by

traderu61
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Function Overloading in C++:

Function overloading allows multiple functions with the same name but different parameters.

Example:

int add(int a, int b);

float add(float a, float b);

2. Polymorphism and Its Types:

Polymorphism means "many forms".

Types:

- Compile-time (Function/Operator Overloading)

- Runtime (Virtual functions & Inheritance)

3. Difference: Function Overloading vs Overriding

| Feature | Overloading | Overriding |

|-----------------|----------------------------------|-------------------------------------|

| Class Involved | Same class | Base and Derived classes |

| Binding Time | Compile-time | Runtime |

| Signature | Different | Same |

4. Function Overloading Example (Area Calculation):

float area(float radius);

int area(int length, int breadth);

5. Friend Function:

A function that can access private members of a class.

Merits: Access to private data, operator overloading support.


Demerits: Breaks encapsulation, increases coupling.

6. Pointer in C++:

A variable that stores the address of another variable.

Advantages: Efficient memory usage, dynamic memory allocation, array handling.

7. Stream in C++:

A stream is a flow of data.

Types:

- Input: cin, ifstream

- Output: cout, ofstream, cerr, clog

8. File I/O in C++:

Classes: ifstream, ofstream, fstream

Functions: open(), close(), is_open(), getline(), read(), write()

Example:

ofstream file("data.txt"); file << "Hello";

ifstream file("data.txt"); getline(file, line);

You might also like