SlideShare une entreprise Scribd logo
1  sur  12
FILE HANDLING
File handling is used to
store data permanently in
a computer.
01
POLYMORPHISM
The word
“polymorphism” means
having many forms.
02
C PRESENTATION
++
The fstream Library
 Ofstream– This class represents an output stream.
It’s used for creating files and writing information to
files.
 Ifstream– This class represents an input stream. It’s
used for reading information from data files.
 Fstream– This class generally represents a file
stream. It comes with ofstream/ifstream capabilities.
This means it’s capable of creating files, writing to
files, reading from data files.
These file modes allow
us to create, read, write,
append or modify a file.
The file modes are
defined in the class ios.
FILE MODES
File Functions
1. open(): To create a file
SYNTAX:-Open (file_name, mode);
2. close(): To close an existing file
SYNTAX:- void close();
3. get(): to read a single character from the file
4. put(): to write a single character in the file
5. read(): to read data from a file
6. write(): to write data into a file
#include<fstream.h>
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char data[100];
ofstream groot;
groot.open("c:oopfile.txt",ios::out);
cout<<"WRITING TO FILE"<<endl;
cout<<"ENTER YOUR NAME"<<endl;
cin.getline(data,100);
groot<<data<<endl;
groot.close();
ifstream hitesh;
hitesh.open("c:oppfile.txt",ios::in);
cout<<"reading from the file"<<endl;
hitesh>>data;
cout<<data<<endl;
hitesh.close();
getch();
}
FILE HANDLING
File handling is used to
store data permanently in
a computer.
01
POLYMORPHISM
The word
“polymorphism” means
having many forms.
02
C PRESENTATION
++
Polymorphism
 Polymorphism :- the same entity
(function or object) behaves
differently in different scenarios.
Real life Example
I am
Polymorphism
Types of Polymorphism
Difference between run-time and compile-time
Run-time Compile-time
1)Run time is the time period where the
executable code is running.
2)Errors can be detected only after the
execution of the program.
3)Errors that occur during the execution
of a program are called run-time errors.
Run time errors aren’t detected by the
compiler.
1)Compile time is the time period where
the code typed is converted into
executable code.
2)Errors are detected before the
execution of the program.
3)Errors that occur during compile time
are called compile-time errors. Two
types of compile-time errors area)
a) semantics error occurs when the
statements aren’t meaningful to the
compiler.
b)Syntax error occurs when the
programmer doesn’t follow the syntax.
Function overloading
#include <iostream>
using namespace std;
class Addition {
public:
int ADD(int X,int Y) // Function with parameter
{
return X+Y; // this function is performing
addition of two Integer value
}
int ADD() { // Function with same name
but without parameter
string a= "HELLO";
string b="SAM"; // in this function
concatenation is performed
string c= a+b;
cout<<c<<endl; }
};
int main(void) {
Addition obj; // Object is created
cout<<obj.ADD(128, 15)<<endl; //first
method is called
obj.ADD(); // second method is called
return 0;
}
Output
143
HELLOSAM
Operator overloading
#include <iostream>
using namespace std;
class A
{
string x;
public:
A(){}
A(string i)
{
x=i;
}
void operator+(A);
void display();
};
void A:: operator+(A a)
{
string m = x+a.x;
cout<<"The result of the addition of two objects is : "<<m;
}
int main()
{
A
a1("Welcome");
A a2("back");
a1+a2;
return 0;
}
Output
Welcomeback
Virtual Function
#include<iostream>
using namespace std;
class base {
public:
virtual void print()
{
cout << "print base classn";
}
void show()
{
cout << "show base classn";
}
};
class derived : public base {
public:
void print()
{
cout << "print derived classn";
}
void show()
{
cout << "show derived classn";
}
};
int main()
{
base *bptr;
derived d;
bptr = &d;
// Virtual function, binded at runtime
bptr->print();
// Non-virtual function, binded at compile
time
bptr->show();
return 0;
}
Output
print derived class
show base class

Contenu connexe

Similaire à C++ppt.pptx

C++ - UNIT_-_V.pptx which contains details about File Concepts
C++  - UNIT_-_V.pptx which contains details about File ConceptsC++  - UNIT_-_V.pptx which contains details about File Concepts
C++ - UNIT_-_V.pptx which contains details about File Concepts
ANUSUYA S
 
Data file handling
Data file handlingData file handling
Data file handling
TAlha MAlik
 

Similaire à C++ppt.pptx (20)

File Handling
File HandlingFile Handling
File Handling
 
File Handling
File HandlingFile Handling
File Handling
 
File handling in_c
File handling in_cFile handling in_c
File handling in_c
 
C++ - UNIT_-_V.pptx which contains details about File Concepts
C++  - UNIT_-_V.pptx which contains details about File ConceptsC++  - UNIT_-_V.pptx which contains details about File Concepts
C++ - UNIT_-_V.pptx which contains details about File Concepts
 
Data file handling
Data file handlingData file handling
Data file handling
 
data file handling
data file handlingdata file handling
data file handling
 
Data file handling
Data file handlingData file handling
Data file handling
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams
 
File in cpp 2016
File in cpp 2016 File in cpp 2016
File in cpp 2016
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))
 
Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008
 
C++ Version 2
C++  Version 2C++  Version 2
C++ Version 2
 
File Handling
File HandlingFile Handling
File Handling
 
Input output files in java
Input output files in javaInput output files in java
Input output files in java
 
File Handling in c++
File Handling in c++File Handling in c++
File Handling in c++
 
C_and_C++_notes.pdf
C_and_C++_notes.pdfC_and_C++_notes.pdf
C_and_C++_notes.pdf
 
File handling.pptx
File handling.pptxFile handling.pptx
File handling.pptx
 
Java IO
Java IOJava IO
Java IO
 
File handling in cpp
File handling in cppFile handling in cpp
File handling in cpp
 
cpp-file-handling
cpp-file-handlingcpp-file-handling
cpp-file-handling
 

Plus de MrGyanprakash (9)

HCI project presentation of their pdfs..
HCI project presentation of their pdfs..HCI project presentation of their pdfs..
HCI project presentation of their pdfs..
 
HCI project Presentation Human Computers
HCI project Presentation Human ComputersHCI project Presentation Human Computers
HCI project Presentation Human Computers
 
IoT internet of thing powerppoint c.pptx
IoT internet of thing powerppoint c.pptxIoT internet of thing powerppoint c.pptx
IoT internet of thing powerppoint c.pptx
 
LiFi Technology powerpoint for bca .pptx
LiFi Technology powerpoint for bca .pptxLiFi Technology powerpoint for bca .pptx
LiFi Technology powerpoint for bca .pptx
 
chemistry presentation on the university
chemistry presentation on the universitychemistry presentation on the university
chemistry presentation on the university
 
ubantu ppt.pptx
ubantu ppt.pptxubantu ppt.pptx
ubantu ppt.pptx
 
Chapter 3 - Conditional Statements
Chapter 3 - Conditional StatementsChapter 3 - Conditional Statements
Chapter 3 - Conditional Statements
 
Chapter 2 - Instructions & Operators
Chapter 2 - Instructions & OperatorsChapter 2 - Instructions & Operators
Chapter 2 - Instructions & Operators
 
Chapter 1 - Variables, Data types + Input/Output
Chapter 1 - Variables, Data types + Input/OutputChapter 1 - Variables, Data types + Input/Output
Chapter 1 - Variables, Data types + Input/Output
 

Dernier

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Dernier (20)

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

C++ppt.pptx

  • 1. FILE HANDLING File handling is used to store data permanently in a computer. 01 POLYMORPHISM The word “polymorphism” means having many forms. 02 C PRESENTATION ++
  • 2. The fstream Library  Ofstream– This class represents an output stream. It’s used for creating files and writing information to files.  Ifstream– This class represents an input stream. It’s used for reading information from data files.  Fstream– This class generally represents a file stream. It comes with ofstream/ifstream capabilities. This means it’s capable of creating files, writing to files, reading from data files.
  • 3. These file modes allow us to create, read, write, append or modify a file. The file modes are defined in the class ios. FILE MODES
  • 4. File Functions 1. open(): To create a file SYNTAX:-Open (file_name, mode); 2. close(): To close an existing file SYNTAX:- void close(); 3. get(): to read a single character from the file 4. put(): to write a single character in the file 5. read(): to read data from a file 6. write(): to write data into a file
  • 5. #include<fstream.h> #include<iostream.h> #include<conio.h> void main() { clrscr(); char data[100]; ofstream groot; groot.open("c:oopfile.txt",ios::out); cout<<"WRITING TO FILE"<<endl; cout<<"ENTER YOUR NAME"<<endl; cin.getline(data,100); groot<<data<<endl; groot.close(); ifstream hitesh; hitesh.open("c:oppfile.txt",ios::in); cout<<"reading from the file"<<endl; hitesh>>data; cout<<data<<endl; hitesh.close(); getch(); }
  • 6. FILE HANDLING File handling is used to store data permanently in a computer. 01 POLYMORPHISM The word “polymorphism” means having many forms. 02 C PRESENTATION ++
  • 7. Polymorphism  Polymorphism :- the same entity (function or object) behaves differently in different scenarios. Real life Example I am Polymorphism
  • 9. Difference between run-time and compile-time Run-time Compile-time 1)Run time is the time period where the executable code is running. 2)Errors can be detected only after the execution of the program. 3)Errors that occur during the execution of a program are called run-time errors. Run time errors aren’t detected by the compiler. 1)Compile time is the time period where the code typed is converted into executable code. 2)Errors are detected before the execution of the program. 3)Errors that occur during compile time are called compile-time errors. Two types of compile-time errors area) a) semantics error occurs when the statements aren’t meaningful to the compiler. b)Syntax error occurs when the programmer doesn’t follow the syntax.
  • 10. Function overloading #include <iostream> using namespace std; class Addition { public: int ADD(int X,int Y) // Function with parameter { return X+Y; // this function is performing addition of two Integer value } int ADD() { // Function with same name but without parameter string a= "HELLO"; string b="SAM"; // in this function concatenation is performed string c= a+b; cout<<c<<endl; } }; int main(void) { Addition obj; // Object is created cout<<obj.ADD(128, 15)<<endl; //first method is called obj.ADD(); // second method is called return 0; } Output 143 HELLOSAM
  • 11. Operator overloading #include <iostream> using namespace std; class A { string x; public: A(){} A(string i) { x=i; } void operator+(A); void display(); }; void A:: operator+(A a) { string m = x+a.x; cout<<"The result of the addition of two objects is : "<<m; } int main() { A a1("Welcome"); A a2("back"); a1+a2; return 0; } Output Welcomeback
  • 12. Virtual Function #include<iostream> using namespace std; class base { public: virtual void print() { cout << "print base classn"; } void show() { cout << "show base classn"; } }; class derived : public base { public: void print() { cout << "print derived classn"; } void show() { cout << "show derived classn"; } }; int main() { base *bptr; derived d; bptr = &d; // Virtual function, binded at runtime bptr->print(); // Non-virtual function, binded at compile time bptr->show(); return 0; } Output print derived class show base class