이 프로그램에서 모양과 오류가 생성됩니다 준비하시기 바랍니다유효하지 않은 사용자 정의 변환
$ g++ inher2.cpp
inher2.cpp: In function ‘int main()’:
inher2.cpp:32:10: error: invalid user-defined conversion from ‘B()’ to ‘const B&’ [-fpermissive]
inher2.cpp:14:6: note: candidate is: B::B(int) <near match>
inher2.cpp:14:6: note: no known conversion for argument 1 from ‘B()’ to ‘int’
inher2.cpp:32:10: error: invalid conversion from ‘B (*)()’ to ‘int’ [-fpermissive]
inher2.cpp:14:6: error: initializing argument 1 of ‘B::B(int)’ [-fpermissive]
당신이 나를 찾을 수 있습니다 : 컴파일시
#include <iostream>
using namespace std;
class A
{
public:
virtual void f(){}
int i;
};
class B : public A
{
public:
B(int i_){i = i_;} //needed
B(){} //needed
void f(){}
};
int main()
{
//these two lines are fixed(needed)
B b;
A & a = b;
//Assignment 1 works
B b1(2);
b = b1;
//But Assignment 2 doesn't works
B b2();
b = b2; // <-- error
}
을, 나는 다음과 같은 오류가 발생합니다 문제? 그것은 함수 선언, 하지 변수 선언을 당신
당신이 그것을 필요로 할 때 가장 괴롭히는 구문 분석 질문은 어디에 있습니까? – chris
@chris 처음에 나는 대답을보기 전 까진 농담을한다고 생각했다. : vexing! ... :) thanks – rahman