mirror of
https://inf-git.fh-rosenheim.de/studavrije7683/cplusplus-training.git
synced 2025-04-19 22:49:55 +00:00
24 lines
580 B
C++
24 lines
580 B
C++
#include <iostream>
|
|
#include <string>
|
|
|
|
using namespace std;
|
|
struct Tier{
|
|
uint8_t id;
|
|
string name;
|
|
bool operator == (const Tier& cmp) const {return id==cmp.id;}
|
|
bool operator < (const Tier& cmp) const {return id-cmp.id;}
|
|
string to_string(){return "ID: "+id+(name.length()>0?("Name: "+name):"")+"\n";}
|
|
};
|
|
int main(){
|
|
Tier tiere[50];
|
|
cout<<"Erstelle Liste\n";
|
|
for(int i = 0;i<50;i++){
|
|
cout<<"Erstelle index "<<i<<endl;
|
|
tiere[i].id=i+1;
|
|
}
|
|
|
|
for(Tier tier:tiere){
|
|
cout<<tier.to_string()<<endl;
|
|
}
|
|
system("pause");
|
|
} |