Posts

Showing posts from March, 2020

C++ File Handling

Image
File Handling in C++ File are used to store the user data for extended time periods. As such the data is stored in permanent device storage. Thus, File handling becomes an essential mechanism to store the output of program or to receive inputs for a program and other various operations. To receive and send data to and from a device, stream is used as an abstraction. Stream is represented as source or destination of characters of indefinite length. In C++, file handling can be done using libraries, as such, ifstream, ofstream and fstream provide the needed functionality. These classes are derived from fstrembase and corresponding iostream class. Thus, any C++ program involving must include fstream library, as these classes are a part of the library. In C++, files are mainly dealt by using three classes fstream, ifstream, ofstream. ofstream: This Stream class signifies the output file stream and is applied to create files for writing information to files ifstream...

Operator Overloading in C++

Image
Operator Overloading What is an operator? Operators are symbolic representation of mathematical or logical operations that can be performed on one or more operands. In C++, there are following operators present: Operator Type Number of operands ++,-- Unary Operator 1 +,-,*,/,% Arithmetic operator 2 <,<=,>,>=,==,!= Relational operator 2 &&,||,! Logical operator 2 &,|,<<,>>,~,^ Bitwise operator 2 =,+=,-=,*=,/=,%= Assignment operator 2 ?: Ternary operator 3 There are some special operators such as . (dot operator), :: (Scope resolution) and sizeof operator. Each of them has a special purpose such as the dot operator is used for Member resolution, :: is used to change the resolution of a assignment or Member and sizeof is a C++ compiler unary operator which is used to determine the memory size of i...