Alright, I’ve got what should be an easy question but there are literally no examples of what I am looking for online, only copies of the same example which does everything in one file. I’m trying to make an interface and a method to use it like the example below, but I am getting unresolved external symbol errors from visual studio when I compile. Any ideas about what I am doing wrong?
IFoo.h
class IFoo {
public:
virutal int Bar();
}
Foo.h
class Foo : public IFoo {
virtual int Bar();
}
Foo.cpp
int Foo::Bar() {
return 1;
}
In IFoo.h, the virtual method must be pure virtual:
Alternately, provide an default implementation, either inline or in an IFoo.cpp. However, that would make the I prefix misleading, as it wouldn’t act like an interface, then.