mirror of
https://github.com/lucaspalomodevelop/cpp_stuff.git
synced 2026-03-12 22:47:22 +00:00
add classes
This commit is contained in:
parent
8e48d9bf91
commit
8dfa5a1a76
12
classes/hund.cpp
Normal file
12
classes/hund.cpp
Normal 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
12
classes/katze.cpp
Normal 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
13
classes/main.cpp
Normal 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
5
classes/makefile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
dev: compile run
|
||||||
|
compile:
|
||||||
|
g++ -o program main.cpp
|
||||||
|
run:
|
||||||
|
./program
|
||||||
BIN
classes/program
Executable file
BIN
classes/program
Executable file
Binary file not shown.
22
classes/tier.cpp
Normal file
22
classes/tier.cpp
Normal 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
6
fibonacci/#main.cpp#
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include<iostream>
|
||||||
|
|
||||||
|
int fib(int n)
|
||||||
|
{
|
||||||
|
return n < 2 ? 1 : fib(n-2)+ fib(n-1);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user