내 클래스 구조는 다음과 같다 :잘못된 초기화 유형
Test_Camera.h :
class Test_Camera : public Camera_Interface {
public:
Test_Camera (string const& aName);
...
Test_Camera.cpp
Test_Camera::Test_Camera(string const& aName) : Camera_Interface(0, 0, 0, 0), name(aName)
에서 Test_Camera
개체를 인스턴스화하는 코드는 2 가지 시나리오가 있습니다. 첫 번째 컴파일은 괜찮지 만 두 번째는 발생하지 않으며 이유를 파악할 수 없습니다. 나는 또한 시도
error: invalid initialization of non-const reference to type 'Test_Camera&' from a temporary of type 'const char*'
:
string name = "cam";
Test_Camera& cam (name); //does not compile
[ints] (http : // ideone)과 동일한 오류 메시지가 표시됩니다. .com/Dlpinm) – Default