Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

4.0 Unit 4 Overview: Templates, Exceptions, Streams & Files

Lesson 18 of 22 in the free Object Oriented Programming with C++ notes on Siksha Sarovar, written by Rohit Jangra.

Unit IV — Overview: Templates, Exceptions, Streams & Files

Unit IV completes the C++ toolkit with three modern features:

  1. Parametric polymorphism / Generic programming via templates
  2. Exception handling — modern error-handling mechanism
  3. Streams and Files — C++'s I/O model

Learning outcomes

After Unit IV you should be able to:

  • Write function templates and class templates
  • Handle template specialisation and overloading
  • Use try/catch/throw for exceptions
  • Catch specific types, catch all (...), rethrow exceptions
  • Specify exception declarations (throw(), noexcept)
  • Use the C++ stream hierarchy (istream, ostream, fstream)
  • Open, read, write, close files
  • Handle file modes (text vs binary; sequential vs random access)
  • Use file pointers (seekg, tellg, seekp, tellp)
  • Implement persistent objects + command-line arguments

Topic map

Chapter mapping (IPU)

  • TB1 (Venugopal): Chapters 16, 17, 18, 19
  • TB2 (Balagurusamy): Chapters 11, 12, 13

Typical exam weight

Unit IV contributes 2-3 long questions:

  • Explain function templates with example. — 12.5 marks
  • Explain class templates with example. — 12.5 marks
  • What is exception handling? Explain try/catch/throw with example. — 12.5 marks (very high)
  • Write a C++ program to read/write a file. — 12.5 marks
  • Explain file pointers and random access in files. — 12.5 marks