|
Error in reverse (string**,int)
|
|
03-12-2010, 07:14 PM
Post: #1
|
|||
|
|||
|
Error in reverse (string**,int)
Hi guys, reverse engineering a data structures piece of code.
The is a function that reverses pointers in an array. The definitio void reverse(string**,int); why does string pointer have 2*? If I remove one, i get the error :cannot convert `std::string**' to `std::string*' for argument `1' to `void print(std::string*, int)' just not sure what it does. thanks |
|||
|
03-12-2010, 07:28 PM
Post: #2
|
|||
|
|||
|
RE: Error in reverse (string**,int)
Whenever there are ** asterisks by a variable in C++ this is indicating that it is expecting a paramater
that is a pointer to a pointer. For example, my first name is Daniel Below is a snippet demonstrating pointer to pointer logic. string* target = new string("Daniel"); string** lockon = ⌖ cout << "Lockon to target: " << **lockon << endl; delete target; So above I have dynamically allocated the target pointer. Then I pass it's address to the lock on pointer. I call the dereferencing operator twice to lock on to the target and output it's contents in memory. Finally I delete the target returning memory for allocation on the heap. Pointers are fun! |
|||
|
« Next Oldest | Next Newest »
|




