main.cpp
#include "library.h"
#include "czworokat.h"
int main(){
Kwadrat*kwadrat=new Kwadrat(5);
cout<<"Pole kwadratu wynosi: "<<Kwadrat.Pole()<<endl;
return 0;
}
czworokat.h
#ifndef czworokat_H
#define czworokat_H
#include "library.h"
#include "kwadrat.h"
class Czworokat{
protected:
int bok1;
int bok2;
public:
int getbok1();
int getbok2();
};
#endif
kwadrat.h
#include "czworokat.h"
class Kwadrat: public Czworokat{
public:
int pole=0;
Kwadrat(int a){
bok1=a;
bok2=a;
}
int Pole(){
pole=a*a;
return pole;
}
};
Wrzucilem tutaj swoj program testowy z dziedziczenia klas, niestety jest problem taki ze nie dziala.(jest jeszcze plik z biblioteka). Co dokladnie w nim nie dziala?(Error jest taki: error: expected class-name before ‘{’ token
class Kwadrat: public Czworokat{
^
kwadrat.h11: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
int pole=0;
^
kwadrat.h: In constructor ‘Kwadrat::Kwadrat(int)’:
kwadrat.h3: error: ‘bok1’ was not declared in this scope
bok1=a;
^
kwadrat.h3: error: ‘bok2’ was not declared in this scope
bok2=a;
^
kwadrat.h: In member function ‘int Kwadrat::Pole()’:
kwadrat.h9: error: ‘a’ was not declared in this scope
pole=a*a;
^
main.cpp: In function ‘int main()’:
main.cpp41: error: expected primary-expression before ‘.’ token
cout<<"Pole kwadratu wynosi: "<<Kwadrat.Pole()<<endl;)