int*: Pointer to an int.
int**: Pointer to a pointer to an int (pointer to an int*).
int***: Ponter to a pointer to a pointer to an int (pointer to an int**).
Have you ever tried creating shortcut to shortcut to a document?
There is a program in Program Files/Program/start.exe (that would be int).
There is a shortcut to that program on Start Menu (that would beint*).
Then the user created a shortcut to the file in Start Menu, that is a shortcut to shortcut to file (that would be int**).
I actually was making a hash table in which a pair was defined using template class as below:
1 2 3 4 5 6 7 8 9 10 11
template <class K, class E>
class hashTable
{
pair<const K, E>** table;
int dSize;
int divisor;
hash<K> h; // hash is a class to convert string to integer
public:
// other functions
}
here it treats table as an array. I am confused how is it defined as array and whether it is a pointer array or just array??
And thanks for the help.. :)
Your table member is defined as a pointer to a pointer to a pair<K, E>. However, pointers can freely point to elements within an array. Usually, a programmer will maintain a pointer to the first element of the array so that they can use the [] notation to get its elements. When you dynamically allocate an array, you're basically allocating a block of memory and making the pointer point to the first element.
A 2D array like you're trying to make (I presume), is, in reality, an array of pointers to arrays. When you allocate a 2D array, you're setting that pointer to point to the first element of an array of pointers, each pointer in turn pointing to the first element of an array of pairs.