Q:

declared name in.h but reports undeclare in .cpp in Xcode

Below is my code:
MathCore.h
#ifndef __CC_MATHCORE_H__
#define __CC_MATHCORE_H__

#include "math.h"
class MathCore
{
public:
    MathCore();
    virtual ~MathCore( );
    int x (int n  );
};

#endif

MathCore.cpp 
#ifndef __CC_MATHCORE_H__
#define __CC_MATHCORE_H__

#include "MathCore.h"

MathCore::MathCore()//a
{

}
MathCore::~ MathCore()//b
{

}
int MathCore::x (int n  )//c
{
    float v=0;
    return v;
}
#endif 

but it erports error at
a:C++ requires a type specifier for all declarations
  Use of undeclared identifier 'MathCore'
b:Expected a class or namespace
c:Expected a class or namespace

Your comment welcome

A:

You shouldn't have that #define in both the .cpp and .h files, as it will prevent the contents of the .h file from actually being included.
When you #include a file, for all practical purposes it behaves the same way as copying and pasting that file into wherever you have the #include. So, the first few lines of your MathCore.cpp are effectively this:
#ifndef __CC_MATHCORE_H__
#define __CC_MATHCORE_H__

#ifndef __CC_MATHCORE_H__
#define __CC_MATHCORE_H__
/* the rest of your .h file here */

When restructured that way, it becomes a little more obvious, that second #ifndef can never match since the symbol it's checking is defined immediately above.

A:

Because, in your C++ file, you're using the same header guards as your header. The second line defines __CC_MATHCORE_H__. After this, you include the header, which does nothing if __CC_MATHCORE_H__ is defined. Remove the guard from the cpp file, and you'll be fine. Guards are rarely, if ever, needed in actual implementation files.

