简体   繁体   中英

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(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.

Replace:

Evidence(A* a, B* b, C* c);

With:

Evidence(A* a, B* b, C* c) {}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM