|
| ||||||||||
| Tags: arrays, java, pointers, visual basic |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Pointers VS Arrays in C++
Last edited by Rum : 18-01-2010 at 12:10 PM. |
|
#2
| ||||
| ||||
| Re: Pointers VS Arrays in C++
According to me, the function of arrays is very much similar/bound to the one of pointers. In fact, the identifier of the arrays is equivalent/same to the address of its first element, as a pointer is equivalent/same to the address of the first element that it points to, this is because i am telling that they both have same concept/function. Example of Arrays and Pointers: int num [30]; int * num; |
|
#3
| |||
| |||
| Re: Pointers VS Arrays in C++
I would say that both Pointers and Arrays are two different things and think cannot be differentiated. Instead of this, i can say that array names can be sued as pointer and it is a const pointer also. In other words, an array name is actually a pointer to the first element of the array. Example: int a[50]; // a is an array of 50 ints. int* pt; // pt is a pointer to an int. pt = a; // Assigns the address of first element of a to pt. pt = &a[0]; // Exactly the same assignment as above. Hope you will be able to get enough knowledge about the pointers and arrays. |
|
#4
| ||||
| ||||
| Re: Pointers VS Arrays in C++
I don't want what will be difference between the pointer and arrays, but surely can give some information about the pointers. Pointer is a variable which will store a memory address. Each and every variable is been located inside the unique location within a computers memory and this unique location is with its own unique address(i.e the memory address). Usually, the variables can hold values such as 7 or “HI” and these values are stored under specific location within computer memory. But pointer is a different beast, because it holds the value of its memory address and also has capability to 'point' ( i.e pointer ) to certain value within a memory, by use of its associated memory address. |
|
#5
| ||||
| ||||
| Re: Pointers VS Arrays in C++
Arrays: In C++, arrays are one of the data structures which you can be used to store/place consecutive values of the same type of data types. Arrays in C++ can also be declared for all data types (i.e int, float, double, char, struct, char etc.) And all the values are stored in consecutive memory locations. The values can be accessed by using the position of the stored value. Pointers: It is a variable which will hold the addresses of another variables/functions/data. The pointer is told to be "point to" the memory address which is stored in it. Example: signed main() { int* pt; //Right now, pt contains no particular myval in this C++ code. } |
|
#6
| ||||
| ||||
| Re: Pointers VS Arrays in C++
I would say that the pointer can be referred to the individual item or to an arrays of items. In fact, the array is only the way of creating both the list of items and the pointers to that lists first item in one declaration. The array and pointer concepts are more or less completely interchangeable. In other words, we can say that subscripts can be useful with the pointers, as if they were arrays held at the address of the pointer. On the other hand, the array can also be used as if it was the pointer. The only difference between the pointers and arrays, is that the address of the array are not able to be changed by assignment.
__________________ Grand Theft Auto 4 PC Video Game |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Pointers VS Arrays in C++" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What are the advantages of pointers? | Owen Fernandes | Software Development | 5 | 09-02-2010 11:39 AM |
| Pointers in C and C++ | unlimitedtech | Guides & Tutorials | 4 | 04-02-2010 11:42 AM |
| Pointer to an array of pointers | pushpendra | Software Development | 3 | 29-12-2009 11:45 AM |
| Are pointers and arrays equivalent | KALINDA | Software Development | 3 | 16-10-2009 06:41 PM |
| Arrays and Pointers in C | Ivy00 | Software Development | 1 | 10-11-2008 04:28 PM |