- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7346 Articles for C++
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
1K+ Views
To catch an exception for both base and derive class then we need to put catch block of derived class before the base class. Otherwise, the catch block of derived class will never be reached.AlgorithmBegin Declare a class B. Declare another class D which inherits class B. Declare an object of class D. Try: throw derived. Catch (D derived) Print “Caught Derived Exception”. Catch (B b) Print “Caught Base Exception”. End.Here is a simple example where catch of derived class has been placed before the catch of base ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
5K+ Views
A pointer is a variable whose value is the address of another variable or memory block, i.e., direct address of the memory location. Like any variable or constant, you must declare a pointer before using it to store any variable or block address.SyntaxDatatype *variable_nameAlgorithmBegin. Define a function show. Declare a variable x of the integer datatype. Print the value of varisble x. Declare a pointer p of the integer datatype. Define p as the pointer to the address of show() function. Initialize value to p pointer. End.This is a simple ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
703 Views
Vectors have the ability to resize itself automatically like dynamic arrays when an element is inserted or deleted, the container handles their storage automatically.The main difference between vector resize() and vector reserve() is that resize() is used to change the size of vector where reserve() doesn’t. reserve() is only used to store at least the number of the specified elements without having to reallocate memory. But in resize(), if the number is smaller than the current number then it resizes the memory and deletes the excess space over it.vector::resize()Vector resize() is used to change its size.ExampleSteps in the source code:Begin ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
3K+ Views
Vectors have the ability to resize itself automatically like dynamic arrays when an element is inserted or deleted, the container handle their storage automatically.The main difference between vector resize() and vector reserve() is that resize() is used to change the size of vector where reserve() doesn’t. reserve() is only used to store at least the number of the specified elements without having to reallocate memory. But in resize() if the number is smaller than the current number then it resizes the memory and deletes the excess space over it.vector::resize()Vector resize() is used to change its size.ExampleSteps in the source code:Begin ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
1K+ Views
The function tmpfile() creates a temporary file in binary update mode in C. It initializes in header file of a C program. It always returns a null pointer if the temporary file cannot be created. The temporary file deleted automatically just after the termination of program.SyntaxFILE *tmpfile(void)Return valueIf file creation is successful, the function returns a stream pointer to the temporary file created. If the file cannot be created, NULL pointer is returned.AlgorithmBegin. Declare an array variable c[] to the character datatype and take a character data string. Initialize a integer variable i ← 0. Declare a ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
In C++ file handling, the tellp() function is used with output streams, and returns the current put position of the pointer in the stream. It returns an integer data type, representing the current position of the stream pointer.tellp() method takes no parameter. It is written as: pos_type tellp();AlgorithmBegin. Create an object newfile against the class fstream. Call open() method to open a file “tpoint.txt” to perform write operation using object newfile. Insert data into the file object newfile. Call the tellp() method to print the present position of the pointer in the file object. Call ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
25K+ Views
This is a C++ program to read file line by line.Inputtpoint.txt is having initial content as "Tutorials point."OutputTutorials point.AlgorithmBegin Create an object newfile against the class fstream. Call open() method to open a file “tpoint.txt” to perform write operation using object newfile. If file is open then Input a string “Tutorials point" in the tpoint.txt file. Close the file object newfile using close() method. Call open() method to open a file “tpoint.txt” to perform read operation using object newfile. If file is open then Declare a ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
11K+ Views
This is a C++ program to read data from a text file.Inputtpoint.txt is having initial content as “Tutorials point.”OutputTutorials point.AlgorithmBegin Create an object newfile against the class fstream. Call open() method to open a file “tpoint.txt” to perform write operation using object newfile. If file is open then Input a string “Tutorials point" in the tpoint.txt file. Close the file object newfile using close() method. Call open() method to open a file “tpoint.txt” to perform read operation using object newfile. If file is open then Declare ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
848 Views
This is a c program to merge the contents of two files into the third file.For Example.Inputjava.txt is having initial content “Java is a programing language.” kotlin.txt is having initial content “ kotlin is a programing language.” ttpoint.txt is having initial content as blankOutputfiles are merged ttpoint.txt will have final content as “Java is a programing language. kotlin is a programing language.”AlgorithmBegin Declare a[] array to the character datatype. Initialize a[] = "Java is a programing language.". Declare i of the integer datatype. Initialize i =0. Declare f1 as a pointer ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
63K+ Views
This is a C++ program to read a text file.Inputtpoint.txt is having initial content as “Tutorials point.”OutputTutorials point.AlgorithmBegin Create an object newfile against the class fstream. Call open() method to open a file “tpoint.txt” to perform write operation using object newfile. If file is open then Input a string “Tutorials point" in the tpoint.txt file. Close the file object newfile using close() method. Call open() method to open a file “tpoint.txt” to perform read operation using object newfile. If file is open then Declare a string ... Read More