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"
|
#include "tier.cpp"
|
||||||
#endif
|
|
||||||
|
|
||||||
class hund : public tier
|
class hund : public tier
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
#ifndef TIER_H //ensuring that this object is only initialized once
|
|
||||||
#include "tier.cpp"
|
#include "tier.cpp"
|
||||||
#endif
|
|
||||||
|
|
||||||
class katze : public tier
|
class katze : public tier
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,12 +1,21 @@
|
|||||||
#include "hund.cpp"
|
#include "hund.cpp"
|
||||||
#include "katze.cpp"
|
#include "katze.cpp"
|
||||||
|
#include "tier.cpp"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
int main(){
|
int main()
|
||||||
katze a;
|
{
|
||||||
std::string laut = a.getLaut();
|
tier arr[2];
|
||||||
std::cout << laut << std::endl;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
BIN
classes/program
BIN
classes/program
Binary file not shown.
@ -4,17 +4,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "tier.h"
|
#include "tier.h"
|
||||||
|
|
||||||
// class tier
|
|
||||||
// {
|
|
||||||
// public:
|
|
||||||
// tier();
|
|
||||||
|
|
||||||
// std::string getLaut();
|
|
||||||
|
|
||||||
// protected:
|
|
||||||
// std::string Laut;
|
|
||||||
// };
|
|
||||||
|
|
||||||
tier::tier()
|
tier::tier()
|
||||||
{
|
{
|
||||||
this->Laut = "void";
|
this->Laut = "void";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user