Podaje kod źródłowy:
Kod: Zaznacz cały
//---------------------------------------------------------------------------
#pragma hdrstop
#include<stdio.h>
#pragma argsused
#include<iostream>
//---------------------------------------------------------------------------
class samochod
{
private:
void dodaj_auto(int,char*,char*,float,int);
void sprawdz_marke(char*);
void sprawdz_cene(int,int);
void wypisz();
samochod();
~samochod();
private:
int rok_produkcji;
char *marka;
char *model;
float cena;
int przebieg;
};
void samochod::dodaj_auto(int rok,char* mar,char*mod,float cen,int przeb)
{
rok_produkcji=rok;
marka=mar;
model=mod;
cena=cen;
przebieg=przeb;
return;
}
void samochod::sprawdz_marke(char* marka3)
{
if (strcmp(marka,marka3)==0) wypisz();
}
void samochod::sprawdz_cene(int cena3,int cena4)
{
if ((cena3>cena) && (cena4<cena)) wypisz();
void samochod::wypisz()
{
cout<<"Rok produkcji samochodu ";
cout<<rok_produkcji;
cout<<endl;
cout<<"Marka samochodu " ;
cout<<marka;
cout<<endl;
cout<<"Przebieg samochodu " ;
cout<<przebieg;
cout<<endl;
return;
}
samochod::samochod()
{
marka= new char [40];
model= new char [40];
return;
}
samochod::~samochod()
{
delete[] marka;
delete[] model;
return;
}
int main(int argc, char* argv[])
{
samochod s[100];
int i,licznik=-1;
int stan_ogloszenia1;
int rok_produkcji1;
char *marka1= new char[40];
char *model1=new float[40];
float cena1;
int przebieg1;
do
{
clrscr();
cout<<"1.Dodaj samochod "<<endl;
cout<<"2.Pokaz samochod "<<endl;
cout<<"3.WYJŚCIE "<<endl;
fflush(stdin);
cin>>i;
switch (i)
{
case 1:
{
cout<<"Podaj rok produkcji samochodu ";
cin>>rok_produkcji1;
cout<<endl;
fflush(stdin);
cout<<"Podaj markę samochodu " ;
gets(marka1);
cout<<endl;
cout<<"Podaj model samochodu " ;
gets(model1);
cout<<endl;
cout<<"Podaj cenę samochodu " ;
cin>>cena1;
cout<<endl;
cout<<"Podaj przebieg samochodu " ;
cin>>przebieg1;
cout<<endl;
licznik+=1;
s[licznik].dodaj_auto(rok_produkcji1,marka1,model1,cena1,przebieg1);
break;
}
case 2:
{
int x;
do
{
clrscr();
cout<<"1.Wyszukaj wg. marki "<<endl;
cout<<"2.Wyszukaj wg. ceny "<<endl;
cout<<"3.Wypisz wszystkie "<<endl;
cout<<"4.WYJŚCIE "<<endl;
fflush(stdin);
cin>>x;
fflush(stdin);
switch(x)
{
case 1:{
char *marka2=int;
cout<<"Podaj markę ";
cin>>marka2;
clrscr();
for (int j=0;j<=licznik;j++)
{
s[j].sprawdz_marke(marka2);
}
getch();
break;
}
case 2:
{
int cena_min,cena_max;
cout<<"Podaj cenę maksymalną ";
cin>>cena_max;
cout<<"Podaj cenę minimalną ";
cin>>cena_min;
clrscr();
for (int j=0;j<=licznik;j++)
{
s.sprawdz_cene(cena_max,cena_min);
}
getch();
break;
}
case 3:
{
for (int j=0;j<=licznik;j++)
{
s[j].wypisz();
}
getch();
break;
}
}}
while (x!=4);
break;
}
case 3:
{
break;
}
}
}
while (i!=3);
delete[] marka1;
delete[] model1;
return 0;
}
//---------------------------------------------------------------------------
Kod: Zaznacz cały
C:\Documents and Settings\Łukasz\Pulpit\Pulpit\spr_c++\samochod_spr.cpp In member function `void samochod::sprawdz_cene(int, int)':
45 C:\Documents and Settings\Łukasz\Pulpit\Pulpit\spr_c++\samochod_spr.cpp expected primary-expression before "void"
45 C:\Documents and Settings\Łukasz\Pulpit\Pulpit\spr_c++\samochod_spr.cpp expected `;' before "void"
62 C:\Documents and Settings\Łukasz\Pulpit\Pulpit\spr_c++\samochod_spr.cpp expected `;' before '{' token
67 C:\Documents and Settings\Łukasz\Pulpit\Pulpit\spr_c++\samochod_spr.cpp no matching function for call to `samochod::samochod()'
note C:\Documents and Settings\Łukasz\Pulpit\Pulpit\spr_c++\samochod_spr.cpp:19 candidates are: samochod::~samochod()
68 C:\Documents and Settings\Łukasz\Pulpit\Pulpit\spr_c++\samochod_spr.cpp expected `;' before '{' token
74 C:\Documents and Settings\Łukasz\Pulpit\Pulpit\spr_c++\samochod_spr.cpp a function-definition is not allowed here before '{' token
74 C:\Documents and Settings\Łukasz\Pulpit\Pulpit\spr_c++\samochod_spr.cpp expected `,' or `;' before '{' token
188 C:\Documents and Settings\Łukasz\Pulpit\Pulpit\spr_c++\samochod_spr.cpp expected `}' at end of input Pozdrawiam Dahra
Już wszystko działa temat do zamknięcia:)