- 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 7401 Articles for C++
20K+ 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.
423 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
645 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
248 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
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
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
397 Views
In the GCC compiler there are some builtin functions. These functions are like below.Function _builtin_popcount(x)This builtin function is used to count the number of 1s in an integer type data. Let us see an example of _builtin_popcount() function.Example Live Demo#include using namespace std; int main() { int n = 13; //The binary is 1101 cout
3K+ Views
In this section we will see what is the wide character in C++. We will also see some functions that are used to handle wide characters.Wide characters are similar to character datatype. The main difference is that char takes 1-byte space, but wide character takes 2-bytes (sometimes 4-byte depending on compiler) of space in memory. For 2-byte space wide character can hold 64K (65536) different characters. So the wide char can hold UNICODE characters. The UNICODE values are international standard which allows for encoding for characters virtually for any character of any language.Example Live Demo#include using namespace std; int main() { ... Read More
661 Views
In this section we will see what is the conversion constructor in C++ class. A constructor is a special type of function of class. It has some unique property like, its name will be same as class name, it will not return any value etc. The constructors are used to construct objects of a class. Sometimes constructors may take some arguments, or sometimes it does not take arguments.When a constructor takes only one argument then this type of constructors becomes conversion constructor. This type of constructor allows automatic conversion to the class being constructed.Example Live Demo#include using namespace std; class my_class{ ... Read More
520 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
To Continue Learning Please Login
Login with Google