std::string 클래스를 상속 받아서 하려면?

inootis의 이미지

std::string를 상속받아서..새로운 기능을 하려합니다..

그런데.. 아래처럼 간단하게 int값으로 변환하는 기능을 추가 했는데..안되네요..

class MyString : public std::string
{
	public :
		int toInt()
		{
			return atoi(this->c_str());
		}
};

MyString str="100";

std::cout << str.toInt();

에러메세지는...

conversion from `const char[4]' to non-scalar type `MyString' requested

std::string operator = 연산자가 수행이 안된는것 같은데..어떻게 해야할찌.

june8th의 이미지

public MyString( const char * buf ) : std::string( buf ) {}