Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Полиморфизм. Простейшее ДЕМО.
#include <iostream> ///--------------------------| /// Интерфейс животного. | ///--------------------------: struct Animal {virtual void speak() = 0; }; ///--------------------------| /// Кот. | ///--------------------------: struct Kat : public Animal { void speak(){ std::cout << "miau\n"; } }; ///--------------------------| /// Собака. | ///--------------------------: struct Dog : public Animal { void speak(){ std::cout << "gavf\n"; } }; ///--------------------------| /// Тест. | ///--------------------------: int main() { Kat kat; Dog dog; Animal* animals[2] = { &dog, &kat}; ///----------------------| /// Разное поведение. | ///----------------------: for(const auto& a : animals) { a->speak(); } }
run
|
edit
|
history
|
help
0
stack::swap_30-Seconds-of-C++
Stock buy/sell, maximum subarray problem
Deque EvenOdd
Rezolvare Ex 4
2021(M2)Simulare:S3:1
Continuous Sub Set with given sum
test
First and last Occurence of an Element
რიცხვები დაფაზა~ფინალური
introduction c-types