Hi,
I'm running into trouble here as I'm programming C++ with QT4.3.
Here's a snippet
Code:
#Asteroid.h
#ifndef ASTEROID_H
#define ASTEROID_H
#include <QPainter>
#include "AsteroidList.h"
class Asteroid
{
public:
Asteroid() { AsteroidList list; }
void addAsteroid(int,int,int);
void displayAsteroid();
void draw(QPainter&);
};
#endif
Code:
#AsteroidList.h
#ifdef ASTEROIDLIST_H
#define ASTEROIDLIST_H
#include <QPainter>
#include "AsteroidNode.h"
class AsteroidList
{
public:
AsteroidList();
Asteroid* first;
void addAsteroid(int,int,int);
void drawAsteroid(QPainter&);
void display();
private:
AsteroidNode* a_first;
};
#endif
Code:
#AsteroidList.cpp
#include "AsteroidList.h"
#include <iostream>
//Default Constructor
AsteroidList::AsteroidList()
{
a_first = NULL;
}
As I compile with QT4.3, I encountered this error
Asteroid.h: In constructor ‘Asteroid::Asteroid()’:
Asteroid.h:15: error: ‘AsteroidList’ was not declared in this scope
Asteroid.h:15: error: expected `;' before ‘list’
Asteroid.cpp: In member function ‘void Asteroid::addAsteroid(int, int, int)’:
Asteroid.cpp:13: error: ‘list’ was not declared in this scope
Asteroid.cpp: In member function ‘void Asteroid::displayAsteroid()’:
Asteroid.cpp:19: error: ‘list’ was not declared in this scope
Asteroid.cpp: In member function ‘void Asteroid::draw(QPainter&)’:
Asteroid.cpp:25: error: ‘list’ was not declared in this scope
What i'm concerned is, why is the AsteroidList class not detected in Asteroid.h file even if I've included them?
Please help.
P.S. The codes are incomplete as I'm focusing only on why the class name is not there.