Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi iam started to study c++ module this sem can help me out, I don't able to understand the meaning of this line `map<int, BST<Data>**>::iterator itr = tree.begin()

	for (map<int, BST<Data>**>::iterator itr = tree.begin(); itr != tree.end(); ++itr)
				{
					if (itr->first == y)
					{
						for (int i = 0; i < 12; i++)
							for (int j = 0; j < 31; j++)
								sum(itr->second[i][j].root, c[i], sumS[i], sumSR[i], sumT[i]);
						break;
					}
				}


What I have tried:

Class Bst is the normal binary search tree programme
Posted
Updated 2-Feb-21 4:14am

An article by yours truly.

Pointer to Pointer and Reference to Pointer[^]
 
Share this answer
 
 
Share this answer
 
I'd suggest to read this: Double Pointer (Pointer to Pointer) in C - GeeksforGeeks[^]

Quote:
We already know that a pointer points to a location in memory and thus used to store the address of variables. So, when we define a pointer to pointer. The first pointer is used to store the address of the variable. And the second pointer is used to store the address of the first pointer. That is why they are also known as double pointers.


Got it?
 
Share this answer
 
v2
It's a pointer to a pointer to data. [Usually] data structures don't store the data themselves but store only a pointer which is then allocated for every element (this allows for the data structures to be generic, i.e. not dependent on the type of the contained data, via templates / generic / casting to and from void* depending on the lanfguage).

In this case the iterator returns a pointer to the data element, which is itself a pointer to the data themselves.

This is not the only way to use double (or multiple) pointers but it is definitely one of the most common.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900