chevron_left

Recent posts tagged pointers

22 0 2 min.
In C++, pointers are often used for allocating resources. Below is one typical use of pointers in C++void function() { Resource* ptr = new Resource(); // allocate resources // do something delete ptr; // free...
posted Sep 4 hhh98hd 226 points
12 0 2 min.
One of the most noticable differences between C++ and other programming languages is the use of pointers. In this article, I am going to explain more about pointers and how to use them in C++. So let’s begin !Unlike other data ty...
posted Aug 24 hhh98hd 226 points
19 0 4 min.
Generally, copying an object means creating a replica of the original object with the same values, data type and resources.In C++, you can copy an object by:MyClass newObj(obj);orMyClass newObj = obj;We need to choose whether to use Shallow Copy...
posted Aug 23 hhh98hd 226 points
18 0 2 min.
In C++, there are 4 types of casting operators:const_caststatic_castdynamic_castreinterpret_castconst_cast operator is used to remove the “constness” of a variable. Below is the usage of const_cast. However, please note tha...
posted Aug 11 hhh98hd 226 points
2 0 2 min.
The -> operator is also known as the arrow operator and it is usually used to refer to individual members in structs, class objects and unions.Unlike dot operators, which are used to access members of objects, arrow operators&n...
posted Aug 7 hhh98hd 226 points
8 0 1 min.
Array is the most popular term when beginning to learn about C++. In this article, I will represent the way to get size of an array.In C++, we get size (in bytes) of a variable usinng the function sizeof(). For example, to get size of an in...
posted Aug 5 hhh98hd 226 points
9 0 2 min.
When working with char arrays or char pointers, you may encounter the error “Invalid conversion from char to const char* [-fpermissive]”. In this article, I will point out the root cause of the error along with the solution to the error. ...
posted Aug 4 hhh98hd 226 points
5 0 1 min.
Along with other data types like int, double, float, string, …, char is one ofthe most widely used type. When working with char variables and char arrays, you may encounter the error “Incompatible types in assignment ...
posted Aug 3 hhh98hd 226 points
2 0 2 min.
In C++, we can declare a 2D array as an “array of arrays” :int arr[num_row][num_col]The above 2D array is able to store maximum num_row * num_col elements.To put data to a 2D array, we use a nested-for loop:for(int i = 0; i <...
posted Aug 3 hhh98hd 226 points
5 0 2 min.
When start to learn C++, you may encounter the error “Invalid conversion from char to const char*”. In this article, I will point out the root cause of the error along with the solution to the error. So let’s begin !Basically, ...
posted Aug 2 hhh98hd 226 points
12 1 4 min.
Раss  а  роinter  tо  а  funсtiоn  in  СDefinitiоn А роinter is  а  vаriаble  thаt  stоres  the  аddress  оf  аnоther  vаriаble.  Unlike  оther &...
posted Jul 11 sakshi 955 points
3 0 1 min.
C++ PointersGiven a string of lowercase english alphabets. The task is to count number of vowels present in a string using pointers.Initialize the string using a character array.Create a character pointer and initialize it with the first element in a...
posted May 7 Ahsan29 43 points
8 0 1 min.
C++ PointersIn C++, pointers are variables that store the memory addresses of other variables.This program declares the array of five element and the elements of that array are accessed using pointer.To understand this example, you should have the kn...
posted May 7 Ahsan29 43 points
3 0 4 min.
C++ PointersIn C++, pointers are variables that store the memory addresses of other variables.Here is how we can declare pointers.int *pointVar; Here, we have declared a pointer pointVar of the int type.We can also declare pointers in the follow...
posted May 7 Ahsan29 43 points
0 0 1 min.
Void is a keyword used in C++ which specifies that a function does not return a value. Also, when used in a function, it means that the functions take no parameters. Similarly, if used in declaration of a pointer, void specifies that the pointer is u...
posted Sep 6, 2020 Lalit Kumar 0 points
32 0 1 min.
Pointers are good to have in your program. But also can be difficult to learn. &ldquo;Indirection Requires Pointer Operand ('Int' Invalid)&rdquo; is an error which occur because of a pointer. I give the cause and the solution of the e...
posted Sep 6, 2020 Lalit Kumar 0 points
0 0 1 min.
An array of pointers is an indexed set of variables which act as pointers i.e. referencing a location in the computer's memory or addressing some other element. The relevance of such pointers is to enhance creation, use and destroying all types o...
posted Aug 11, 2020 Lalit Kumar 0 points
0 0 2 min.
Errors are the mistakes or faults in the program that cause our program to behave unexpectedly and it is no doubt that the well versed and experienced programmers also make mistakes. Sometimes the cause of the error is small enough to be ignored and ...
posted Jun 30, 2020 Lalit Kumar 0 points
47 1 2 min.
Errors are the mistakes or faults in the program that cause our program to behave unexpectedly and it is no doubt that the well versed and experienced programmers also make mistakes.Sometimes the cause of the error is small enough to be ignored and t...
posted Jun 26, 2020 Lalit Kumar 0 points
13 0 1 min.
The problem we are going to discuss today is “How to get the number of elements in an array in C++”. First of all we will discuss the approach or the algorithm and then we will write a program to do so.ApproachUsing size operatorWe know t...
posted Jun 18, 2020 Lalit Kumar 0 points