Category: C++ Interview Questions
this pointer in C++ | Tutorial & Example
What is this pointer ? this pointer is pointer that is accessible only inside the member functions of a class and points to the object who has called this member function. Let’s understand by an example, Rise of this pointer : Behind the scene Let’s understand this pointer in a step by step example, Create …
What is rvalue reference in C++11
In this article we will discuss what is rvalue reference and how it is different from lvalue reference. lvalue references Prior to C++11 we only had references i.e. A Reference variable is an alias that always points to a an existing variable i.e. Advertisements int x = 7; int & refX = x; // refX …
C++11 Move Contsructor & rvalue References
In this article we will discuss the use of rvalue references in C++11 move semantics. Problem of Temporary Objects The Idea behind this move semantics is to reduce the load of these temporary objects on memory. Every time we return a object from a function then a temporary object is created, which eventually get copied. In then …
Need of Operator Overloading in C++ ? | Tutorial and Examples
In this article we will discuss what is operator overloading in C++, why do we need it and how to overload an operator for a user defined class. What is Operator overloading ? Operator Overloading means providing multiple definition for the same operator. Advertisements For example, using + operator with two integers will add the …
Need of Operator Overloading in C++ ? | Tutorial and ExamplesRead More
Unary Operator Overloading in C++ using both member & Friend function
In this article we will discuss how to overload unary operators in c++ using both member and Friend function. What is an unary operator? An Unary operator is an operator that operates on a single operand and returns a new value. Advertisements Some of the unary operators are, ++ (Increment Operator) —   (Decrement operator) –    (Unary …
Unary Operator Overloading in C++ using both member & Friend functionRead More
Overloading Postfix / Prefix ( ++ , –) Increment and Decrements Operators in C++
In this article we will discuss how to overload postfix and prefix increment and decrement operators in c++. Both increment and Decrement operators are of two types i.e. Prefix & Post. Advertisements Prefix-Increment (++x) and Prefix Decrement (–x) Operator In case of prefix increment or decrement operators symbol ++ or — comes before the operand …
Overloading Postfix / Prefix ( ++ , –) Increment and Decrements Operators in C++Read More
How to read data from a csv file in C++ ?
In this article we will discuss and create a class to read data from a CSV File. What is a CSV File ? A csv file is a kind of flat file used to store the data. In this each row contains data separated by comma. For example, Advertisements 20,hi,99 3,4,5 a,b,c 3,4,1 Creating a …
How to write data in a CSV file in C++
In this article we will discuss, how to create a class to write data to a CSV File. What is a CSV File ? A CSV file is a kind of flat file used to store the data. In this each row contains data separated by comma. For example, Advertisements 20,hi,99 3,4,5 a,b,c 3,4,1 Creating …
C++ : How to read or write objects in file | Serializing & Deserializing Objects
In this article we will discuss how to write objects to file and how to read them back from to file and fill in object. Suppose we have a class Student i.e. class Student { public: std::string mName; std::string mId; std::string mPhoneNumber; Student(std::string id = “”, std::string name = “”, std::string phone = “”) : …
C++ : How to read or write objects in file | Serializing & Deserializing ObjectsRead More
C++ : How to read a file line by line into a vector ?
In this article we will discuss how to read a file line by line and put them in a vector or perform some other operation each line. Reading File line by line First open the file i.e. Advertisements // Open the File std::ifstream in(“file.txt”); Now keep reading next line using getline() and push it in …
C++ : How to read a file line by line into a vector ?Read More