Grade XII · Computer Science · Unit 1
Unit 1 · Object Oriented Programming in C++ (30 Marks)
- Review of C++ covered in Class XI.
- Object Oriented Programming concepts - data hiding, data encapsulation, class and object, abstract and concrete classes, polymorphism (function overloading as example), inheritance; advantages of OOP over earlier methodologies.
- Class implementation in C++ - definition of a class; data members and member functions; private and public visibility modes (default: private); defining member functions inside and outside class using scope resolution operator; declaring objects and accessing members; objects as function arguments (pass by value and by reference).
- Constructors - special characteristics; declaration and definition; default constructor; overloaded constructors; copy constructor; constructor with default arguments.
- Destructor - characteristics; declaration and definition.
- Inheritance - base and derived class; defining derived classes; protected visibility mode; single, multilevel and multiple inheritance; privately, publicly and protectedly derived classes; accessibility of members.
- Data file handling in C++ - need for data files; text and binary files; creating and writing text files; reading and manipulating text files sequentially.
- Binary file handling - creation, writing, searching, appending, insertion (in sorted file), deletion and modification of records.
- C++ components for file handling: header file fstream.h; ifstream, ofstream, fstream classes; opening text/binary files in in, out and app modes; use of open(), get(), put(), getline(), read(), write(), close(); detecting end-of-file (with/without eof()); tellg(), tellp(), seekg(), seekp() functions.
- Pointers - declaration and initialization; dynamic memory allocation and deallocation using new and delete.
- Pointers and arrays - array of pointers, pointer to one-dimensional array; functions returning a pointer; reference variables and aliases; call by reference; pointers to structures; dereference operators * and ->; self-referential structures.