Untitled
unknown
c_cpp
7 months ago
495 B
3
Indexable
#include <iostream> class Animale{ protected: std::string nome; public: Animale(std::string n) : nome(n) {} void mangia() { std::cout << nome << " sta mangiando." << std::endl; } }; class Cane : public Animale{ public: Cane(std:: string n): Animale(n) {} void abbaia() { std::cout << nome << " dice: Bau Bau!" << std::endl; } }; int main() { Cane mioCane("Fido"); mioCane.mangia(); mioCane.abbaia(); return 0; }
Editor is loading...
Leave a Comment