- 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++
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
3K+ Views
Dangling pointerDangling pointer is a pointer pointing to a memory location that has been freed (or deleted). There are different ways where Pointer acts as dangling pointerFunction CallThe pointer pointing to local variable becomes dangling when local variable is not static.int *show(void) { int n = 76; /* ... */ return &n; }OutputOutput of this program will be garbage address.De-allocation of memoryint main() { float *p = (float *)malloc(sizeof(float)); //dynamic memory allocation. free(p); //after calling free() p becomes a dangling pointer p = NULL; //now p no more a dangling pointer. }Variable goes ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
2K+ Views
In this section, we will see what are the differences between *ptr++, *++ptr and ++*ptr in C++.Here we will see the precedence of postfix++ and prefix++ in C or C++. The precedence of prefix ++ or -- has higher priority than dereference operator ‘*’ and postfix ++ or -- has a priority higher than both prefix ++ and dereference operator ‘*’.When ptr is a pointer, then *ptr++ indicates *(ptr++) and ++*prt refers ++(*ptr)Example Code Live Demo#include using namespace std; int main() { char arr[] = "Hello World"; char *ptr = arr; ++*ptr; cout
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
4K+ Views
In C++ the size of the character literal is char. In C the type of character literal 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 Code Live Demo#include main() { printf("%d", sizeof('a')); }Output1Example Code Live Demo#include using namespace std; main() { cout
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
349 Views
An interface describes the behavior or capabilities of a C++ class without committing to a particular implementation of that class.The C++ interfaces are implemented using abstract classes and these abstract classes should not be confused with data abstraction which is a concept of keeping implementation details separate from associated data.A class is made abstract by declaring at least one of its functions as a pure virtual function. A pure virtual function is specified by placing "= 0" in its declaration as follows −class Box { public: // pure virtual function virtual double getVolume() ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
383 Views
In C++ we can pass arguments into a function in different ways. These different ways are −Call by ValueCall by ReferenceCall by AddressSometimes the call by address is referred to as call by reference, but they are different in C++. Incall by address, we use pointer variables to send the exact memory address, but in call by reference we pass the reference variable (alias of that variable). This feature is not present in C, there we have to pass the pointer to get that effect.In this section, we will see what are the advantages of call by reference over call ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
6K+ Views
In this section, we will see how to get the current working directory using C or C++. We have defined some flags for the current operating system.Example Code Live Demo#ifdef WINDOWS #include #define GetCurrentDir _getcwd #else #include #define GetCurrentDir getcwd #endif #include using namespace std; std::string get_current_dir() { char buff[FILENAME_MAX]; //create string buffer to hold path GetCurrentDir( buff, FILENAME_MAX ); string current_working_dir(buff); return current_working_dir; } main() { cout
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
619 Views
Dangling pointerDangling pointer is a pointer pointing to a memory location that has been freed (or deleted). There are different ways where Pointer acts as dangling pointerFunction CallThe pointer pointing to local variable becomes dangling when local variable is not static.int *show(void) { int n = 76; /* ... */ return &n; }OutputOutput of this program will be garbage address.De-allocation of memory#include #include int main() { float *p = (float *)malloc(sizeof(float)); //dynamic memory allocation. free(p); //after calling free() p becomes a dangling pointer p = NULL; //now p no more a dangling pointer. ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
7K+ Views
In C and C++ the single quote is used to identify the single character, and double quotes are used for string literals. A string literal “x” is a string, it is containing character ‘x’ and a null terminator ‘\0’. So “x” is two-character array in this case.In C++ the size of the character literal is char. In C the type of character literal 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++.
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
95 Views
AVL tree is a self-balancing Binary Search Tree where the difference between heights of left and right subtrees cannot be more than one for all nodesTree rotation is an operation that changes the structure without interfering with the order of the elements on an AVL tree. It moves one node up in the tree and one node down. It is used to change the shape of the tree, and to decrease its height by moving smaller subtrees down and larger subtrees up, resulting in improved performance of many tree operations. The direction of a rotation depends on the side which ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
2K+ Views
The (int)x is C style typecasting where static_cast(x) is used in C++. This static_cast() gives compile time checking facility, but the C style casting does not support that. This static_cast() can be spotted anywhere inside a C++ code. And using this C++ cast the intensions are conveyed much better.In C like cast sometimes we can cast some type pointer to point some other type data. Like one integer pointer can also point character type data, as they are quite similar, only difference is character has 1-byte, integer has 4-bytes. In C++ the static_cast() is more strict than C like casting. ... Read More