Yes you're right. Sorry.Quote:
Originally Posted by Daved
Passing by value is like this:Code:#include <iostream>
#include <string>
using namespace std;
void SomeFunction(string** pointerToStringPointer)
{
cout << "pointerToStringPointer = 0x" << hex << reinterpret_cast<unsigned int>(pointerToStringPointer) << endl;
**pointerToStringPointer = "Goodbye world!";
}
int main()
{
string helloString = "Hello world!";
string* pointerToHelloString = &helloString;
string** pointerToHelloStringPointer = &pointerToHelloString;
cout << "helloString = 0x" << hex << reinterpret_cast<unsigned int>(&helloString) << endl;
cout << "pointerToHelloString = 0x" << hex << reinterpret_cast<unsigned int>(pointerToHelloString) << endl;
cout << "pointerToHelloStringPointer = 0x" << hex << reinterpret_cast<unsigned int>(pointerToHelloStringPointer) << endl;
SomeFunction(pointerToHelloStringPointer);
cout << helloString;
};
Code:#include <iostream>
#include <string>
using namespace std;
void SomeFunction(string theString)
{
theString = "Goodbye World!";
}
int main()
{
string helloString = "Hello world!";
string* pointerToHelloString = &helloString;
string** pointerToHelloStringPointer = &pointerToHelloString;
SomeFunction(**pointerToHelloStringPointer);
cout << helloString;
};