#include <iostream>
#include <string>
#include <vector>
struct Feature {
float x;
float y;
float value;
} ;
class BaseClass {
public :
int GetDetections( const std:: string & filename) const {
// Normally, I'd read in features from a file, but for this online
// example, I'll just construct an feature set manually.
std:: vector < Feature> features;
return GetDetections( features) ;
} ;
// Pure virtual function.
virtual int GetDetections( const std:: vector < Feature> & features) const = 0 ;
} ;
class SubClass : public BaseClass {
public :
// Giving the pure virtual function an implementation in this class.
int GetDetections( const std:: vector < Feature> & features) const {
return 7 ;
}
} ;
int main( ) {
SubClass s;
std:: cout << s.GetDetections ( "testfile.txt" ) ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgoKc3RydWN0IEZlYXR1cmUgewogIGZsb2F0IHg7CiAgZmxvYXQgeTsKICBmbG9hdCB2YWx1ZTsKfTsKCmNsYXNzIEJhc2VDbGFzcyB7CiAgcHVibGljOgogICAgaW50IEdldERldGVjdGlvbnMoY29uc3Qgc3RkOjpzdHJpbmcmIGZpbGVuYW1lKSBjb25zdCB7CiAgICAgICAgLy8gTm9ybWFsbHksIEknZCByZWFkIGluIGZlYXR1cmVzIGZyb20gYSBmaWxlLCBidXQgZm9yIHRoaXMgb25saW5lCiAgICAgICAgLy8gZXhhbXBsZSwgSSdsbCBqdXN0IGNvbnN0cnVjdCBhbiBmZWF0dXJlIHNldCBtYW51YWxseS4KICAgICAgICBzdGQ6OnZlY3RvcjxGZWF0dXJlPiBmZWF0dXJlczsKICAgICAgICByZXR1cm4gR2V0RGV0ZWN0aW9ucyhmZWF0dXJlcyk7CiAgICB9OwogICAgLy8gUHVyZSB2aXJ0dWFsIGZ1bmN0aW9uLgogICAgdmlydHVhbCBpbnQgR2V0RGV0ZWN0aW9ucyhjb25zdCBzdGQ6OnZlY3RvcjxGZWF0dXJlPiYgZmVhdHVyZXMpIGNvbnN0ID0gMDsKfTsKCmNsYXNzIFN1YkNsYXNzIDogcHVibGljIEJhc2VDbGFzcyB7CiAgcHVibGljOgogICAgLy8gR2l2aW5nIHRoZSBwdXJlIHZpcnR1YWwgZnVuY3Rpb24gYW4gaW1wbGVtZW50YXRpb24gaW4gdGhpcyBjbGFzcy4KICAgIGludCBHZXREZXRlY3Rpb25zKGNvbnN0IHN0ZDo6dmVjdG9yPEZlYXR1cmU+JiBmZWF0dXJlcykgY29uc3QgewogICAgICAgIHJldHVybiA3OwogICAgfQp9OwoKaW50IG1haW4oKSB7CiAgICBTdWJDbGFzcyBzOwogICAgc3RkOjpjb3V0IDw8IHMuR2V0RGV0ZWN0aW9ucygidGVzdGZpbGUudHh0Iik7Cn0=
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:33:48: error: no matching function for call to ‘SubClass::GetDetections(const char [13])’
prog.cpp:33:48: note: candidate is:
prog.cpp:26:9: note: virtual int SubClass::GetDetections(const std::vector<Feature>&) const
prog.cpp:26:9: note: no known conversion for argument 1 from ‘const char [13]’ to ‘const std::vector<Feature>&’
stdout