Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Object-Oriented Programming (OOP) Notes – C++ | 6 Units | B.Tech Computer Engineering

Rating
-
Sold
-
Pages
14
Uploaded on
14-06-2025
Written in
2024/2025

These are complete, well-organized notes for the subject Object-Oriented Programming in C++ for Computer Engineering students. Covers all 6 units Includes concepts, syntax, examples, and explanations Based on B.Tech syllabus (suitable for Indian engineering colleges) Typed and easy to understand Useful for exam prep, assignments, and viva revision.

Show more Read less
Institution
Course

Content preview

PCC Unit 6 NOTES + QUES BANK
🔹 1. Streams in C++

 A stream is a flow of data (input/output).
 Used for cin (input), cout (output), and file handling.
 All stream classes are based on the base class ios.
🔹 2. Types of Streams

 istream: for input (cin)
 ostream: for output (cout)
 iostream: for both input & output
 ifstream: read from file
 ofstream: write to file
 fstream: read & write both
🔹 3. Steps for File Handling

1. Create stream object (ifstream, ofstream, fstream)
2. Open the file (file.open("file.txt"))
3. Read/Write
4. Close the file (file.close())
🔹 4. File Modes

Use with open() function:
 ios::in – Read mode
 ios::out – Write mode
 ios::app – Append mode
 ios::binary – Binary file mode
 ios::trunc – Delete old content
 ios::ate – Start at end of file
🔹 5. Basic File Programs

Write to file:
ofstream file("data.txt");
file << "Hello!";
file.close();
Read from file:
ifstream file("data.txt");

, string line;
getline(file, line);
cout << line;
file.close();
🔹 6. File Error Handling Functions

 eof() – End of file
 fail() – Fail to read/write
 bad() – Serious error
 good() – Everything is OK
🔹 7. File Pointers

Used to move around in a file.
 seekg() – set input (get) position
 seekp() – set output (put) position
 tellg() – get input position
 tellp() – get output position
🔹 8. cerr vs clog

 cerr – prints error messages, no buffer, appears immediately
 clog – logs info, is buffered
🔹 9. Binary File I/O

 Use ios::binary mode
file.write((char*)&obj, sizeof(obj));
file.read((char*)&obj, sizeof(obj));


1. Explain the concept of stream and files with example.
In C++, a stream is a flow of data — either into the program (input) or out of the program
(output). It acts like a channel between the program and an input/output device or file.
There are two main types of streams:
 Input stream: used to read data (e.g., cin)
 Output stream: used to write data (e.g., cout)
C++ uses special classes to handle files:
 ifstream – to read from a file
 ofstream – to write to a file

Written for

Institution
Course

Document information

Uploaded on
June 14, 2025
Number of pages
14
Written in
2024/2025
Type
Class notes
Professor(s)
Rucha
Contains
All classes

Subjects

$12.59
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
rucha2

Also available in package deal

Get to know the seller

Seller avatar
rucha2 Hyderabad Univerisity
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
10 months
Number of followers
0
Documents
8
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions