Im stuck with using a class from a library in a selfmade class. I think i understood the fundemantals of using classes and inheritance but somehow im trying for two days now and still cant solve my problem. So help would be very much appreciated.
Here is the code:
Asteroid.hpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#ifndef _ASTEROID_HPP
#define _ASTEROID_HPP
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
class Asteroid : public sf::Shape {
private:
float X;
float Y;
float Radius;
const sf::Color& Col;
float Outline;
const sf::Color& OutlineCol;
public:
Asteroid(float X, float Y, float Radius, const Color& Col, float Outline = 0.f, const Color& OutlineCol = sf::Color(0, 0, 0))
: sf::Shape::Circle(X, Y, Radius, Col, Outline, OutlineCol) {}
Asteroid(const Asteroid& orig);
virtual ~Asteroid();
};
#endif // _ASTEROID_HPP
|
Asteroid.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include "Asteroid.hpp"
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics/Drawable.hpp>
Asteroid::Asteroid(float X, float Y, float Radius, const sf::Color& Col, float Outline, const sf::Color& OutlineCol)
{
sf::Shape::Circle(X, Y, Radius, Col, Outline, OutlineCol);
}
Asteroid::Asteroid(const Asteroid& orig) {
}
Asteroid::~Asteroid() {
}
|
Here is what the compiler has to say:
In file included from main.cpp:9:
Asteroid.hpp:22: error: expected `,' or `...' before '&' token
Asteroid.hpp:23: error: ISO C++ forbids declaration of `Color' with no type
Asteroid.hpp: In constructor `Asteroid::Asteroid(float, float, float, int)':
Asteroid.hpp:23: error: expected class-name before '(' token
Asteroid.hpp:23: error: uninitialized reference member `Asteroid::Col'
Asteroid.hpp:23: error: uninitialized reference member `Asteroid::OutlineCol'
main.cpp: In function `int main(int, char**)':
main.cpp:131: error: no matching function for call to `Asteroid::Asteroid(float, float, float, sf::Color, float, sf::Color)'
Asteroid.hpp:25: note: candidates are: Asteroid::Asteroid(const Asteroid&)
Asteroid.hpp:23: note: Asteroid::Asteroid(float, float, float, int)