Question

In C++

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 as address of variables.

The declaration for the second function is given below-

   int BitmapHashMap::Insertnew(const std::string& key, std::string& value)

How do I use the clsname and objname parameters from first function to invoke the second function above. The second function(within itself) extracts the values of 'key' and 'value' from the parameters and then uses them.

Was it helpful?

Solution

If I understand your question right, you want to know how to pass by reference. Parameters to the second function are already being passed by reference. So the answer to your question would be simply:

void insertobjectnames(std::string clsname, std::string objname) {
    BitmapHashMap hashmap;
    hashmap.Insertnew(clsname, objname);
}

Of course this toy example doesn't make sense as it is, but you haven't told us why you need the first function.

OTHER TIPS

you just call the function with clsname as the parameter, the compiler will do the job for you

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top