mirror of
https://inf-git.fh-rosenheim.de/studavrije7683/cplusplus-training.git
synced 2026-06-29 01:23:21 +00:00
investigated the options to return an array from a function
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#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");
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user