include iostream include string class MyString public MyString const s

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <string>
class MyString
{
public:
MyString(const std::string& theStr = ""):m_Impl(theStr)
{}
operator const char *()
{
return m_Impl.c_str();
}
operator std::string()
{
return m_Impl;
}
private:
std::string m_Impl;
};
int main()
{
MyString s("Hello, world");
std::string somestr(s);//ambiguity
}