tags:

views:

351

answers:

7

Hello, I have my own class inside the file "Particles.h" and the class's implementation is inside "Particles.cpp"

and I want the file "Load.h" to recognize my classes inside there,so I've added the line
#include "Particles.h"
and the file doesn't recognizes it,and at the past everything was ok(I havn't made any changes inside that class).

what should I do?(C++)

A: 

Please provide more information, like simplified contents of your header files, and the erorr messages you get from the compiler.

Alexey Feldgendler
+2  A: 

It sounds like your include path - the list of directories that the compiler scans in order to locate files that you #include - is set incorrectly. Which compiler are you using?

A: 

make sure the file "Particles.cpp" has also included "Particles.h" to start with and the files are in the same folder and they are all part of the same project. it will help if you also share the error message that you are getting from your compiler.

Steve Obbayi
A: 

Dev C++,It uses GCC, The line is:

Stone *stone[48];

and it says: "expected constructor, destructor, or type conversion before '*' token ".

+1  A: 

Well, if you listed your error codes, it might help. Off the top of my head, do you have something in Particles.h to make sure that the file is only included once? There are two methods of doing this. The first is to use #pragma once, but I think that might be Microsoft specific. The second is to use a #define. Example:

#ifndef PARTICLES_H 
#define PARTICLES_H

class CParticleWrapper
{
...
};

#endif

Also, unless you're deriving from a class in Particles.h or using an instance of a class instead of a pointer, you can use a forward declaration of the class and skip including the header file in a header file, which will save you compile time.

#ifndef LOAD_H
#define LOAD_H

class CParticleWrapper;

class CLoader
{
   CParticleWrapper * m_pParticle;

public:

   CLoader(CParticleWrapper * pParticle);
   ...
};  

#endif

Then, in the Load.cpp, you would include the particle.h file.

CariElf
A: 

Please provide all error messages you have got. I am sure this is only one of them. It will help to understand your problem. Not alwaays the first error is the reason of others.

A: 

It sounds like you need to include the definition of the Stone class, but it would be impossible to say without more details. Can you narrow down the error by removing unrelated code and post that?

Eclipse