how to fix error: unknown type name ‘namespace’

Question:


#ifndef UNO_ACTION_ 
#define UNO_ACTION_
namespace Uno
{
namespace Game
{
    class Game;
}
} // namespace

namespace Uno
{
namespace Action
{
using ::Uno::Game::Game;

class Action
{
public:
    virtual bool isDisposeable() = 0;
    virtual void takeAction(Game* game) = 0;
    virtual ~Action() {}
};

}
}
#endif
I compile these code on ubutun 12.04 and it return to set of error:
action.h:4:1: error: unknown type name namespace
action.h:4:15: error: expected ‘=’, ‘,’, ‘;’, asm or __attribute__ before ‘{’ token
action.h:8:1: error: unknown type name namespace
action.h:8:15: error: expected ‘=’, ‘,’, ‘;’, asm or __attribute__ before ‘{’ token
I don't know how to solve these errors.

Solution:

 It sounds like you're trying to compile your C++ code with a C compiler. Trying using g++ instead of gcc and giving your file a C++ extension such as .cpp (rather than .c).

 


Comments

Popular posts from this blog

How to draw an overlay on a SurfaceView used by Camera on Android?

Create EditText with dropdown in android

Android TCP Connection Chat application