Reputation: 61
This is the function I am coding now-
insertobjectnames(std::string clsname, std::string objname)
Now within the above function I have to invoke another function that takes as input the same parameters as above 2, but first one as string and second one as string pointer variable
The declaration for the second function is given below-
int analyse(const std::string key, std::string * key2)
How do I use the objname
parameter from the first function to invoke the second function above? The second function (within itself) extracts the value of key2
from the parameters and then uses them as per requirements.
Upvotes: 0
Views: 71
Reputation: 8805
The &
operator in C++: its the address-of operator: basically a variable to pointer converter! Ex:
int a = 0;
int *pointertoa = &a;
//So
std::string s;
std::string *ps = &s; //Extracting the "key" ps is a pointer to s
analyse(key, &objname); //should be the right way to pass the parameter as a pointer
Upvotes: 1