answersLogoWhite

0


Best Answer

A pointer is simply a variable that can store a memory address and has the same purpose in both languages. The only real difference is that C++ pointers can point at objects (instances of a class) and indirectly invoke their methods, whereas pointers in C (which is not object oriented) cannot.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

An array is a collection of objects of similar data type ,whereas pointers are variable which is used to hold the address of the other variable.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Difference between array and pointers in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between c plus plus and java programming?

Java doesn't have pointers. C++ has pointers.


What is the difference between pointers in c and c plus plus?

Nothing.


Is it possibly to return an array of strings in a function without using pointers in C plus plus?

No.


What is the difference between a C plus plus string and a C-style string?

A std::string is an object that encapsulates an array of type char whereas a C-style string is a primitive array with no members. A std::string is guaranteed to be null-terminated but a C-style string is not.


What is the difference between array in c and c sharp language?

The syntax to access a particular element in an array are the same in both languages: For example: assume array is an array of 10 int(egers): to get the first element: array[0] (both are 0 based indexing] int i = 0; while (i < array.Length) { // do something to array[i] } int i = 0; int length = sizeof(array) / sizeof(int); while (i < length) { // do something to array[i] } However, an array in C# is also enumerable (C does not have this feature) in C#, you may loop thru the array by: foreach (int number in array) { // do something to array[i] } Plus, C# is an Object-Oriented Language, so that an array may be of some object types, not just those primitiives data types in C: object[] objectArray; // any object derived from Object may be placed into objectArray, not just struct. In another variation, an array may be of Delegate type in C#(sort of like function pointers in C)


How do you use string in bubble sort in c plus plus code?

Do you mean how do you sort strings using bubble sort? void exch( std::string& a, std::string& b) { std::string tmp = a; a = b; b = tmp; } void bubble_sort( std::string A[], size_t size ) { size_t last_exch, left, right; while( size ) { for( left=0, right=1, last_exch=left; right<size; ++left, ++right) if( A[right]<A[left] ) exch( A[left], A[last_exch=right] ); size = last_exch; } } Clearly this is inefficient. A better approach would be to use an array of pointers to strings, and swap the pointers instead. The same can be said of any array of objects: use an array of pointers to the objects, never store the objects themselves in the array that is to be sorted.


Difference between null and empty in c plus plus?

NULL is a constant with the value zero. It is typically used with pointers to signify the pointer is valid, but it does not store a valid memory address. In other words it points at nothing in particular. It is nullified. All pointers that are not currently in use must be nullified to signify the fact they are not in use. The term empty applies to arrays that have no elements: empty arrays. We also use the term when referring to empty strings. A string is simply an array of char, but while null-terminated strings always have at least one char, the null-terminator, the string itself is empty.


What is the difference between private stafford and plus student loans?

What is the difference between private stafford and plus student loans?


What is the lowest subscript of an array in c plus plus?

The lowest subscript of an array in C, or C++ is 0.


Program in c plus plus to delete an element in sorted array?

If the array is dynamic then use a vector instead of an array. You can then use the vector::erase() function to delete an element or a range of elements. Remember that if the vector contains pointers to unshared memory, then you must release the pointer before erasing the element containing that pointer. If the array is static then you cannot delete elements. The assumption with static arrays is that you will neither add nor delete, you will only modify existing elements. However, you can emulate a deletion by shunting elements to the left, and keeping track of how many used elements there are (which must always be less than or equal to the upper bound plus one). Again, if the array contains pointers to unshared memory, you must release the pointer before shunting elements. You can also do the same thing with dynamic C-style arrays, but once you've shunted elements to the left you can reallocate the array with the new size to physically delete the final element.


What is the difference between be plus ing and get plus ing?

There are no such terms in C++.


How do you declare a string array and add elements to it in C plus plus?

You cannot add elements to a fixed array in C or C++. If, however, the array is declared as a pointer to an array, you can add elements by allocating a new array, copying/adding elements as needed, reassigning the new array to the pointer, and deallocating the original array.