add classes

This commit is contained in:
lucaspalomodevelop 2022-11-05 12:55:04 +01:00
parent 8e48d9bf91
commit 8dfa5a1a76
7 changed files with 70 additions and 0 deletions

12
classes/hund.cpp Normal file
View File

@ -0,0 +1,12 @@
// #include "tier.cpp"
class hund : public tier
{
public:
hund();
};
hund::hund() : tier()
{
Laut = "wuff";
}

12
classes/katze.cpp Normal file
View File

@ -0,0 +1,12 @@
// #include "tier.cpp"
class katze : public tier
{
public:
katze();
};
katze::katze() : tier()
{
Laut = "miau";
}

13
classes/main.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "tier.cpp"
#include "hund.cpp"
#include "katze.cpp"
#include <stdio.h>
#include <iostream>
#include <string>
int main(){
katze a;
std::string laut = a.getLaut();
std::cout << laut << std::endl;
return 0;
}

5
classes/makefile Normal file
View File

@ -0,0 +1,5 @@
dev: compile run
compile:
g++ -o program main.cpp
run:
./program

BIN
classes/program Executable file

Binary file not shown.

22
classes/tier.cpp Normal file
View File

@ -0,0 +1,22 @@
#include<stdio.h>
#include <string>
class tier{
public:
tier();
std::string getLaut();
protected:
std::string Laut;
};
tier::tier() {
this->Laut = "void";
}
std::string tier::getLaut()
{
return this->Laut;
}

6
fibonacci/#main.cpp# Normal file
View File

@ -0,0 +1,6 @@
#include<iostream>
int fib(int n)
{
return n < 2 ? 1 : fib(n-2)+ fib(n-1);
}