CPP OOP FileHandling Notes
CPP OOP FileHandling Notes
------------------------------------------------------------
1. POLYMORPHISM
Polymorphism means "many forms". In C++, it allows objects to behave differently based on their
types.
Types:
------------------------------------------------------------
2. FUNCTION OVERLOADING
Function Overloading means defining multiple functions with the same name but different
parameters.
Example:
void show();
void show(int);
------------------------------------------------------------
3. VIRTUAL FUNCTION
A virtual function is a function in a base class that can be overridden in a derived class using the
'virtual' keyword.
Example:
class Base {
public:
};
public:
};
------------------------------------------------------------
4. ABSTRACT CLASS
An abstract class contains at least one pure virtual function and cannot be instantiated.
Example:
class Shape {
public:
};
------------------------------------------------------------
------------------------------------------------------------
6. TRY-CATCH BLOCK
try {
} catch (exception_type e) {
// handler code
------------------------------------------------------------
7. EXCEPTION PROPAGATION
If an exception is not caught in the current function, it propagates back to the calling function.
Example:
main() {
try { B(); }
------------------------------------------------------------
8. FILE INPUT AND OUTPUT OPERATIONS
Classes:
Writing Example:
ofstream out("file.txt");
out.close();
Reading Example:
ifstream in("file.txt");
string line;
in.close();
Modes:
------------------------------------------------------------
END OF NOTES