Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ Articles - Page 669 of 719
4K+ Views
To convert fahrenheit to celsius, use a simple mathematical formula. In this article, we are going to discuss the conversion formula, a simple example, and an easy example code. We have been given a temperature in fahrenheit and our task is to convert the given temperature into celsius using C++. Understanding Fahrenheit to Celsius Formula The formula for converting the given temperature from fahrenheit to celsius is as follows: celsius = (fahrenheit - 32.0) * 5.0 / 9.0; Let's see an example to convert the temperature given in fahrenheit to celsius using the above formula: Input: Temperature in ... Read More
4K+ Views
Random numbers are the numbers that are unpredictable and we do not use any pattern or algorithm for choosing them. They are used to bring randomness such as while shuffling data or used in games. To generate a random number in C++, the built-in functions from different libraries such as or can be used. In this article, we will understand four different approaches for generating a random number. The approaches are listed below. Using rand() with srand() Functions Using rand() with Range Limit Using random_device ... Read More
347 Views
In this article we will see how to fill the whole memory by writing a simple C++ program. Here the logic is very simple. We shall create new integer variables by using the dynamic memory allocation. If we create some variables again and again, it will fill the entire primary memory.In C++ to dynamically allocate a memory space we can use the new keyword.The basic syntax of the new operator is like below.pointer_var = new data_typeTo deallocate the memory space, we can use the delete keyword. The syntax isdelete pointer_varNote After running this program it may slow down the performance ... Read More
3K+ Views
We can easily check the Odd or Even by using conditional statements. We can divide the number by 2, then check whether the remainder is 0 or not. If 0, then it is even. We can also perform the AND operation with the number and 1. If the answer is 0, then it is even; otherwise odd. There is no need to use conditional statements in both approaches. We will see two different methods to check the odd or even. Using Modulo Operator The Modulo Operator performs the division operation ... Read More
16K+ Views
Operator overloading in C++ is the feature that allows you to define how operators will behave for user-defined data types like classes and structures. Operator overloading and function overloading both support compile-time polymorphism. In the following article, we will learn the rules that need to be followed for operator overloading. Rules for Operator Overloading Only built-in operators can be overloaded. If some operators are not present in C++, we cannot overload them. The arity of the operators cannot be changed. The precedence and associativity of the operators ... Read More
105 Views
The C++ function std::unordered_multimap::operator=() assigns new contents to the unordered_multimap by replacing old ones and modifies size if necessary.Following is the declaration for std::unordered_multimap::operator=() function form std::unordered_map() header.C++11 (Syntax)unordered_multimap& operator=(const unordered_multimap& umm);Parametersumm - Another unordered_multimap object of same type.Return ValueReturns this pointer.Example Code#include #include using namespace std; int main(void) { unordered_multimap umm1 = { {'a', 1}, {'b', 2}, {'c', 3}, {'d', 4}, {'e', 5}, }; unordered_multimap umm2; umm2 = umm1; cout
12K+ Views
In C++ we can overload some operators like +, -, [], -> etc. But we cannot overload any operators in it. Some of the operators cannot be overloaded. These operators are like below? “.” Member access or dot operator? “? : ” Ternary or conditional operator? “::” Scope resolution operator? “.*” Pointer to member operator? “sizeof” The object size operator? “typeid” Object type operatorThese operators cannot be overloaded because if we overload them it will make serious programming issues.For an example the sizeof operator returns the size of the object or datatype as an operand. This is evaluated by the ... Read More
4K+ Views
The Copy constructor and the assignment operators are used to initializing one object to another object. The main difference between them is that the copy constructor creates a separate memory block for the new object. But the assignment operator does not make new memory space. It uses the reference variable to point to the previous memory block.Copy Constructor (Syntax)classname (const classname &obj) { // body of constructor }Assignment Operator (Syntax)classname Ob1, Ob2; Ob2 = Ob1;Let us see the detailed differences between Copy constructor and Assignment Operator.Copy ConstructorAssignment OperatorThe Copy constructor is basically an overloaded constructorAssignment operator is ... Read More
1K+ Views
In C++ when we want to create a new object, we have to create a memory block into the memory, then also call constructor to initialize the memory block. We can create memory element by using the new keyword. This new operator is doing two consecutive task. But the operator new just only create memory space.New KeywordThe new operator is a special type of operator, which denotes a request for memory allocation on the heap section. When sufficient memory is available, then only new operators initializes the memory to the pointer variable. When we create an object using a normal ... Read More