#include <iostream>
#include<time.h>
#include <stdlib.h>
usingnamespace std;
enum state {initial_state, qu_landing,arriving, qu_takeoff, departing, crash};
int airplane_id=1;
int queue_id=1;
class Random{ //classe Random***********************************************
public:
Random();
~Random();
int rndm_plane();
};
Random::Random(){}
Random::~Random(){}
int Random::rndm_plane(){
srand(time(NULL));
return rand()%11;
}
class Timer { //classe Timer**********************************************
public:
Timer();
~Timer ();
int begin();
};
Timer::Timer(){}
Timer::~Timer(){}
int Timer::begin(){
bool interval=0;
int rndm;
time_t start,now;
double def = 0;
Random rnd;
time(&start);
do{
time(&now);
def=now-start;
if(def==2){//interval de temps
interval=1;
rndm=rnd.rndm_plane();}
}
while(interval==0);
return rndm;
}
class Airplane{ //classe Airplane*******************************************
public:
int id_plane;
int fuel_unit;
state airplane_state;
public:
Airplane();
~Airplane();
void sort(Airplane);
int land();
int takeoff();
int get_id_plane();
int get_fuel_unit();
state get_airplane_state();
};
Airplane::Airplane(){
this->id_plane=airplane_id;
this->fuel_unit=(rand()%25)+25;
this->airplane_state=qu_landing;
}
Airplane::~Airplane(){}
int Airplane::land(){}
int Airplane::takeoff(){}
void sort(Airplane TAB[100]){
Airplane temp;
for(int i=0;i<100;i++){
for(int j=0;j<100;j++){
if (TAB[j+1].fuel_unit<TAB[j].fuel_unit){
temp=TAB[j];
TAB[j]=TAB[j+1];
TAB[j+1]=temp;}
}}
for(int i=0;i<100;i++){ //afficher tableau
cout<<"TAB["<<i<<"] = "<<TAB[i].id_plane<<endl;
cout<<"TAB["<<i<<"] = "<<TAB[i].fuel_unit<<endl;
cout<<"TAB["<<i<<"] = "<<TAB[i].airplane_state<<endl;}
}
int Airplane::get_id_plane(){}
int Airplane::get_fuel_unit(){}
state Airplane::get_airplane_state(){}
class Landing{ //classe Landing*********************************************
private:
int lqueue_id;
Airplane plane;
int Ltime_access_qu;
int arriving_time;
public:
Landing();
int chk_success_arriv();
int get_size_lqueue();
int pop_lqu();
int give_priority();
int get_lqu_state();
int is_dangerous();
};
/*Landing::Landing(){
this->lqueue_id=queue_id;
this->plane=
this->
this->
}*/
class Takeoff{ //classe Takeoff*********************************************
private:
Airplane plane;
int tqueue;
int tsize_qu;
int ttime_access_qu;
int departure_time;
int tflight_id;
public:
Takeoff();
int push_tqu();
int get_tqu_state();
int get_success_dep();
int pop_tqu();
};
//Takeoff::Takeoff(){}
class queu_manager{ //classe Manager********************************************
private:
Landing arr_lqueue[100];
Takeoff arr_tkfqueue[100];
public:
};
//*****************************************************************************************************************************
int main(){
Timer strt;
int aleat;
Airplane A[100];
int A_indice=0;
Airplane aa;
for(int count=0;count<=2;count++){//nembre d'intervale d'execution de la simul
cout<<"interval "<<count<<endl;
aleat=strt.begin();
cout<<"Random! "<<aleat<<endl<<endl;
for(int x=0;x<=aleat-1;x++){
A[x+A_indice]=aa;
cout<<"A[ "<<x+A_indice<<" ]"<<A[x+A_indice].id_plane<<endl;
cout<<"A[ "<<x+A_indice<<" ]"<<A[x+A_indice].fuel_unit<<endl;
cout<<"A[ "<<x+A_indice<<" ]"<<A[x+A_indice].airplane_state<<endl<<endl;
airplane_id++;}
A_indice+=aleat;}
aa.sort(A);
return 0;
}
----------------------------------------------
[Error] C:\Documents and Settings\mido.FS-920E66AC3E25\Mes documents\test.cpp:178: no matching function for call to `Airplane::sort (Airplane[100])'
[Error] C:\Documents and Settings\mido.FS-920E66AC3E25\Mes documents\test.cpp:62: candidates are: void Airplane::sort(Airplane)
Would you mind editing your post and putting the source inside code tags? It will make it a lot more legible and folks here will be more likely to look at it.
class Airplane{
void sort(Airplane); //receives one object Airplane
};
//void Airplane::sort(Airplane) missing implementation
void sort(Airplane TAB[100]){ //a function (not a method) that receives an array of size 100
int main(){
Airplane A[100];
Airplane aa;
//...
aa.sort(A); //calling the method that receives just one object
Is not responsability of an airplane to sort the others. It should be a function. But that already exists so use std::sort(A, A+100, comparator);.
You could overload operator<, make a class with operator() or a function that tells you when an airplane is less than another