fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Interfaceable {
  5. public:
  6. virtual void Interface() = 0; // isto é um método puramente virtual
  7. };
  8.  
  9. class Classe: public Interfaceable {
  10. public:
  11. void Interface();
  12. };
  13.  
  14. void Classe::Interface() {
  15. cout << "interface\n";
  16. }
  17.  
  18. void Teste(Interfaceable& p) {
  19. p.Interface();
  20. }
  21.  
  22. int main() {
  23. auto x = Classe();
  24. x.Interface();
  25. Teste(x);
  26. return 0;
  27. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
interface
interface