Untitled
unknown
plain_text
17 days ago
1.0 kB
4
Indexable
Never
#include <bits/stdc++.h> using namespace std; class Creature { int Height; void Die() { cout << "salem 3 el shohada el m3aaaak.....\n"; } protected: int Weight; public: int Age; Creature(int age) : Age(age) {} Creature(int age , int height) : Age(age) , Height(height) {} void Move() { cout << "Creatre is moving.....\n"; } }; class Human : public Creature{ public: int ID; Human() : Creature(10) { Weight = 20; } Human(int age, int weight) : Creature(age) { Weight = weight; } void Think() { cout << "human is thinking....\n"; } }; void solve() { Human h; Creature *ptr = &h; cout << ptr->Age << '\n'; ptr->Move(); Human h2 = (Human)(*ptr); } int32_t main() { std::ios::sync_with_stdio(false); ios_base::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr); int t = 1; //cin >> t; while (t--)solve(); }
Leave a Comment