#include <iostream>
#include <fstream>
class Base {
public:
virtual std::string GetName() = 0; // pure virtual function
};
class Example : public Base {
private:
std::string m_Name;
public:
Example(const std::string& name)
: m_Name(name) {}
std::string GetName() override { return m_Name; } // have to implement
};
int main() {
// Base* b = new Base(); // Error: object of abstract class type "Base" is not allowed:
// function "Base::GetName" is a pure virtual function
Example* e = new Example("Example");
std::cout << e->GetName() << "\n";
}
/*
run:
Example
*/