mirror of
https://github.com/lucaspalomodevelop/cpp_stuff.git
synced 2026-03-12 22:47:22 +00:00
add polymorphism
This commit is contained in:
parent
e254149b8d
commit
6e2edbdd96
@ -1,6 +1,5 @@
|
||||
#ifndef TIER_H // ensuring that this object is only initialized once
|
||||
#include "tier.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
class hund : public tier
|
||||
{
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
#ifndef TIER_H //ensuring that this object is only initialized once
|
||||
#include "tier.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
class katze : public tier
|
||||
{
|
||||
|
||||
@ -1,12 +1,21 @@
|
||||
#include "hund.cpp"
|
||||
#include "katze.cpp"
|
||||
#include "tier.cpp"
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main(){
|
||||
katze a;
|
||||
std::string laut = a.getLaut();
|
||||
std::cout << laut << std::endl;
|
||||
int main()
|
||||
{
|
||||
tier arr[2];
|
||||
arr[0] = katze();
|
||||
arr[1] = hund();
|
||||
|
||||
for (size_t i = 0; i < 2; i++)
|
||||
{
|
||||
std::string laut = arr[i].getLaut();
|
||||
std::cout << laut << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
classes/program
BIN
classes/program
Binary file not shown.
@ -4,17 +4,6 @@
|
||||
#include <string>
|
||||
#include "tier.h"
|
||||
|
||||
// class tier
|
||||
// {
|
||||
// public:
|
||||
// tier();
|
||||
|
||||
// std::string getLaut();
|
||||
|
||||
// protected:
|
||||
// std::string Laut;
|
||||
// };
|
||||
|
||||
tier::tier()
|
||||
{
|
||||
this->Laut = "void";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user