- 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)
3K+ Views
A hash table is a data structure which is used to store key-value pairs. Hash function is used by hash table to compute an index into an array in which an element will be inserted or searched.This is a C++ program to Implement Hash Tables chaining with singly linked lists.AlgorithmFor insert:Begin Declare Function Insert(int k, int v) int hash_v = HashFunc(k) HashTableEntry* p = NULL HashTableEntry* en = ht[hash_v] while (en!= NULL) p = en en= en->n ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
461 Views
A hash table is a data structure which is used to store key-value pairs. Hash function is used by hash table to compute an index into an array in which an element will be inserted or searched.This is a C++ Program to Implement Hash Tables Chaining with List Heads.AlgorithmFor insert:Begin Declare function Insert(int k, int v) int hash_v = HashFunc(k) if (ht[hash_v] == NULL) ht[hash_v] = new ListHead(k, v) else ListHead *en = ht[hash_v] while (en->n != NULL) ... Read More
![Jennifer Nicholas](https://www.tutorialspoint.com/assets/profiles/13569/profile/60_88876-1512715262.jpg)
195 Views
In this article, we will see what is the conversion operator in C++. C++ supports object-oriented design. So we can create classes of some real-world objects as concrete types.Sometimes we need to convert some concrete type objects to some other type objects or some primitive datatypes. To make this conversion we can use conversion operator. This is created like operator overloading function in class.In this example, we are taking a class for complex numbers. It has two arguments real and imaginary. When we assign the object of this class into some double type data, it will convert into its magnitude ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
Stack and heap are used to store variables during the execution of the program and it also get destroyed.Global data structures or global variables are not consumed by stack or heap. They basically allocated in a fixed memory block, which remains unchanged.int a[10]; // located in a fixed memory block int main() { int main() { float *ptr = (int *)malloc(sizeof(float)10.0)); //use heap. } }
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
21K+ Views
Dereferencing is used to access or manipulate data contained in memory location pointed to by a pointer. *(asterisk) is used with pointer variable when dereferencing the pointer variable, it refers to variable being pointed, so this is called dereferencing of pointers. int main() { int a = 7, b ; int *p; // Un-initialized Pointer p = &a; // Stores address of a in ptr b = *p; // Put Value at ptr in b }Here, address in p is basically address of a variable.
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
444 Views
In this section we will see what are the differences between void pointer in C and void pointer in C++. They are both void pointers but in C a void pointer can be assigned to any pointer type, but in C++, we cannot do that. In C++ we have to explicitly typecast for assigning.In the following example these lines can be executed when we are writing some codes in C.void *p; int *int_ptr = p;This will work fine in C. Now if we use malloc() to allocate some memory spaces, we can use the explicit typecast, but if we do ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
702 Views
In C++ the size of the character constants is char. In C the type of character constant is integer (int). So in C the sizeof(‘a’) is 4 for 32bit architecture, and CHAR_BIT is 8. But the sizeof(char) is one byte for both C and C++.Example Live Demo#include main() { printf("%d", sizeof('a')); }Output4Example Live Demo#include using namespace std; main() { cout
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
264 Views
In C we cannot use function name at the left hand side of an expression. In C++ we can use it like that. This can be done by some function which returns some reference variable.A C++ function can return a reference in a similar way as it returns a pointer.When a function returns a reference, it returns an implicit pointer to its return value. This way, a function can be used on the left side of an assignment statement. For example, consider this simple program −Example Live Demo#include #include using namespace std; double vals[] = {10.1, 12.6, 33.1, 24.1, ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
18K+ Views
In this section we will see how to define an array of strings in C++. As we know that in C, there was no strings. We have to create strings using character array. So to make some array of strings, we have to make a 2-dimentional array of characters. Each rows are holding different strings in that matrix.In C++ there is a class called string. Using this class object we can store string type data, and use them very efficiently. We can create array of objects so we can easily create array of strings.After that we will also see how ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
8K+ Views
In this section we will see how to create and use complex numbers in C++. We can create complex number class in C++, that can hold the real and imaginary part of the complex number as member elements. There will be some member functions that are used to handle this class.In this example we are creating one complex type class, a function to display the complex number into correct format. Two additional methods to add and subtract two complex numbers etc.Example Live Demo#include using namespace std; class complex { int real, img; public: complex() { ... Read More