[英]Constructor of a inherited class in C++
I am doing a project that contains two classes: Evidence and Image(son of Evidence) 我正在做一个包含两个类的项目:证据和图像(证据之子)
The constructor of Evidence is: 证据的构造函数为:
Evidence(A* a, B* b, C* c);
The constructor of the inherited class Image is: 继承的类Image的构造函数为:
Image(A* a, B* b, C* c): Evidence(a,b,c){... code...}
The compiler throws me the following error: 编译器向我抛出以下错误:
In file included from src/evidence/Image.cpp:8:
src/evidence/Image.h:22: error: no matching function for call to
'Evidence::Evidence(A*&, B*&, C*&)'
src/evidence/Evidence.h:35: note: candidates are: Evidence::Evidence(A*, B*, C*)
src/evidence/Evidence.h:21: note: Evidence::Evidence(const Evidence&)
What is wrong? 怎么了? I am so confused that I hurt myself.
我很困惑,我受伤了。
You declared your Evidence
constructor, but you did not actually define it. 您声明了
Evidence
构造函数,但实际上并未定义它。
Replace: 更换:
Evidence(A* a, B* b, C* c);
With: 带有:
Evidence(A* a, B* b, C* c) {}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.