// A7.cpp - explicit construction of function parameter #include using namespace std; class X { public: explicit X(const char *s) { val = s; } string& value() { return val; } void aFunction(const X &x) const { cout << "\n internal string = \"" << val.c_str() << "\""; const string temp = x.val; cout << "\n argument string = \"" << temp.c_str() << "\""; } private: string val; }; void main() { X x("internal string"); ///////////////////////////////////////////////////////////////////// // This won't compile because implicit conversions are not allowed. // x.aFunction("this is an argument string"); x.aFunction(X("this is an argument string")); cout << "\n\n"; }