강의

멘토링

커뮤니티

Inflearn Community Q&A

No author

This post's author information has been deleted.

Minimum C++ for C developers

[Practice Project: CMyString] String Filter Implementation - Step09

단순대입 오류 발생 이유

Resolved

Written on

·

224

0

기본클래스의 =연산자 메서드를 파생클래스형식 인스턴스에서 호출할 수 있을텐데 data="Hello" 오류 발생하는 이유가 궁금합니다.

 

아래 메서드에서 반환하는 인스턴스의 데이터형은 CMystringEx인데 메서드에서 지정한 반환 형식은 CMystring이라서 그런 것인가요?

 

CMystring& CMystring::operator= (const char * pParam)

{this -> setdata(pParam);

return *this;}

 

 

c++객체지향

Answer 1

1

nullnull8537님의 프로필 이미지
nullnull8537
Instructor

연산자 함수는 일반 메서드와 달리 형식이 명확히 일치해야 문법오류가 없습니다. 기본 클래스인 CMyString 클래스에 단순 대입연산자가 있다고 하더라도 그것이 파생형식으로까지 확장되지는 않습니다. 참고하시기 바랍니다. 😄

No author

This post's author information has been deleted.

Ask a question