아래의 스 니펫과 유사한 코드를 컴파일하려고합니다.내부 (중첩 된) 구조체에 기본 ctor가 필요한 이유는 무엇입니까?
class System
{
private:
struct Configuration
{
Configuration(/*params*/);
Configuration(const Configuration&);
Configuration& operator=(const Configuration&);
~Configuration();
/* member variables */
} m_config;
explicit System(const Configuration& cfg);
// Non copyable constructable, non assignable
System(const System&);
System& operator= (const System&);
public:
System();
~System();
}
//Implementation
System::System()
{
m_config = Configuration(/*default params*/);
// ....
}
컴파일러 오류 : 'System :: Configuration :: Configuration()'에 대한 호출과 일치하는 함수가 없습니다.
중첩 된 구조체의 기본 생성자에 대한 정의가 아닌 선언이라 할지라도 오류는 사라집니다 - 왜?!
기타 세부 사항 : gcc 버전 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
어디서'Configuration' 개체를 사용하고 있습니까? –
+1은 문제를보기에 충분한 코드를 제공하려고 시도했지만 -1은 오류 자체를 재현하기위한 실제 사용 사례를 제공하지 못했기 때문입니다. :) – GManNickG
GMan : 죄송합니다. 단점을 깨닫고 발췌문을 편집했습니다. 귀하의 의견을 게시하는 바로 그 시점과 같습니다.) – oompahloompah