Pisze program w ktorym klasa wr dziedziczy z klasy zawodnik wszystkie argumenty. Klasa wr jest rozszerzona wzgledem klasy zawodnik o metody.
Niestety w trakcie kompilacji wyskakuje blad:(
Plik main:
#include "boisko.h"
#include "zawodnik.h"
#include "wr.h"
using namespace std;
extern boisko ekran;
int * tablica;
int * krok;
int * sciezka;
int * gracz;
int * pozycja;
int main()
{
int zawodnicy;
krok = new int[ 24 ];
int * w_krok = krok;
sciezka = new int[ zawodnicy ];
int * w_sciezka = sciezka;
wr gracz[] =
{
wr( "WR", 9, 81, 1, 0, pozycja[ 0 ], sciezka[ 0 ] ),
wr( "WR", 7, 82, 2, 0, pozycja[ 1 ], sciezka[ 1 ] ),
wr( "WR", 4, 83, 3, 0, pozycja[ 2 ], sciezka[ 2 ] ),
wr( "WR", 3, 84, 4, 0, pozycja[ 3 ], sciezka[ 3 ] ),
};
plik wr.h:
#ifndef WR_H_
#define WR_H_
#include <iostream>
using namespace std;
class wr
: public zawodnik
{
public:
wr( const char * nazwa, int speed, int nr, int kt_gracz, int step, int poz, int way )
: zawodnik( nazwa, speed, nr, kt_gracz, step, poz, way )
{
}
void quick_out( int * krok, int * sciezka, int czas, int z );
void slant( int * krok, int * sciezka, int czas, int z );
void out( int * krok, int * sciezka, int czas, int z );
void in( int * krok, int * sciezka, int czas, int z );
void w_prawo( int * krok, int * sciezka, int czas, int z );
void w_lewo( int * krok, int * sciezka, int czas, int z );
void wypisz()
{
cout << "\t # " << numer << "\t" << nazwisko << "\t" << " szybkosc : " << szybkosc << endl;
}
void pozycja_zaw( int * tablica, int rozmiar )
{
for( int porzadkowanie = 0; porzadkowanie < rozmiar; porzadkowanie++ )
{
if( tablica[ porzadkowanie ] ==( numer + 100 ) )
{
tablica[ porzadkowanie ] = 0; }
}
tablica[ pozycja ] = numer + 100;
}
friend class boisko;
};
#endif
plik zawodnik.h:
#ifndef ZAWODNIK_H_
#define ZAWODNIK_H_
#include <iostream>
#include<cstring>
using namespace std;
class zawodnik
{
char nazwisko[ 40 ];
int szybkosc;
int numer;
int ktory_gracz;
int pozycja;
int sciezka;
int krok;
public:
zawodnik( const char * nazwa, int speed, int nr, int kt_gracz, int step, int poz, int way )
{
strcpy( nazwisko,( nazwa ? nazwa: "Anonim" ) );
szybkosc = speed;
pozycja = poz;
numer = nr;
ktory_gracz = kt_gracz;
sciezka = way;
step = krok;
}
friend class boisko;
friend class wr;
};
#endif
Komunikat z kompilatora:
||=== Build: Debug in mecz (compiler: Copy of GNU GCC Compiler) ===|
||WARNING: Can't read file's timestamp: D:\C++\mecz\pilka.cpp|
D:\C++\mecz\wr.h|9|error: expected class-name before '{' token|
D:\C++\mecz\wr.h||In constructor 'wr::wr(const char*, int, int, int, int, int, int)':|
D:\C++\mecz\wr.h|16|error: class 'wr' does not have any field named 'zawodnik'|
D:\C++\mecz\wr.h||In member function 'void wr::wypisz()':|
D:\C++\mecz\wr.h|31|error: 'numer' was not declared in this scope|
D:\C++\mecz\wr.h|31|error: 'nazwisko' was not declared in this scope|
D:\C++\mecz\wr.h|31|error: 'szybkosc' was not declared in this scope|
D:\C++\mecz\wr.h||In member function 'void wr::pozycja_zaw(int*, int)':|
D:\C++\mecz\wr.h|40|error: 'numer' was not declared in this scope|
D:\C++\mecz\wr.h|46|error: 'pozycja' was not declared in this scope|
D:\C++\mecz\wr.h|46|error: 'numer' was not declared in this scope|
D:\C++\mecz\WR .cpp||In member function 'void wr::quick_out(int*, int*, int, int)':|
D:\C++\mecz\WR .cpp|13|error: 'pozycja' was not declared in this scope|
D:\C++\mecz\WR .cpp|17|error: 'szybkosc' was not declared in this scope|
D:\C++\mecz\WR .cpp||In member function 'void wr::slant(int*, int*, int, int)':|
D:\C++\mecz\WR .cpp|69|error: 'pozycja' was not declared in this scope|
D:\C++\mecz\WR .cpp|72|error: 'szybkosc' was not declared in this scope|
D:\C++\mecz\WR .cpp||In member function 'void wr::out(int*, int*, int, int)':|
D:\C++\mecz\WR .cpp|116|error: 'pozycja' was not declared in this scope|
D:\C++\mecz\WR .cpp|119|error: 'szybkosc' was not declared in this scope|
D:\C++\mecz\WR .cpp||In member function 'void wr::in(int*, int*, int, int)':|
D:\C++\mecz\WR .cpp|163|error: 'pozycja' was not declared in this scope|
D:\C++\mecz\WR .cpp|166|error: 'szybkosc' was not declared in this scope|
D:\C++\mecz\WR .cpp||In member function 'void wr::w_prawo(int*, int*, int, int)':|
D:\C++\mecz\WR .cpp|214|error: 'pozycja' was not declared in this scope|
D:\C++\mecz\WR .cpp|219|error: 'szybkosc' was not declared in this scope|
D:\C++\mecz\WR .cpp||In member function 'void wr::w_lewo(int*, int*, int, int)':|
D:\C++\mecz\WR .cpp|241|error: 'pozycja' was not declared in this scope|
D:\C++\mecz\WR .cpp|244|error: 'szybkosc' was not declared in this scope|
||=== Build failed: 20 error(s), 1 warning(s) (0 minute(s), 1 second(s)) ===|
Czy możecie napisać co jest nie tak??
Dzieki za pomoc