inheritance problem

Hello Guys

im trying to build a class with inheritance. I read a few online tutorials about it but i dont get the point.
I tried to draw a circle with the class sf::Shape but my compiler keeps screaming "undefined reference to `Asteroid::Asteroid()'"

So here is the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef _ASTEROID_H
#define	_ASTEROID_H
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>

class Asteroid : public sf::Shape {
private:

public:
    Asteroid(); 
    
    Asteroid(const Asteroid& orig);
    virtual ~Asteroid();


};

#endif	/* _ASTEROID_H */ 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "Asteroid.h"
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>


double radiAsteroid = 50;

Asteroid::Asteroid() {
    sf::Shape::Circle(400, 400, radiAsteroid, sf::Color(255, 255, 255));

}

Asteroid::Asteroid(const Asteroid& orig) {
    
}

Asteroid::~Asteroid() {
}


main.cpp
1
2
Asteroid asteroidclass;
Game.Draw(asteroidclass);
You aren't linking against Asteroid.cpp.

The implementation of your default constructor looks wrong too.
And an empty copy constructor cannot be good.
Topic archived. No new replies allowed.