Error: using typedef-name after class

I can not understand what the real problem is with this.

typedef struct _actor
{
   ...
} _actor, Actor;

class Actor
{
   ...
};

I get this strange error message actor.cpp:31: error: using typedef-name โ€˜Actorโ€™ after โ€˜classโ€™.

Any idea what I did wrong here? Thank:)

+3
source share
3 answers

You are not allowed to define a character Actormore than once. The operator typedefalready defines the character Actoras an alias for struct _actorbefore attempting to declare a class with the same name.

I assume you are using a compiler gcc. When compiling with gccI get the following errors:

../src/main.cpp:113: error: using typedef-name โ€˜Actorโ€™ after โ€˜classโ€™
../src/main.cpp:111: error: โ€˜Actorโ€™ has a previous declaration here

( class Actor ) , typedef-name (Actor typedef). ( typedef struct _actor ) Actor.

C/++ , , , .

+4

, , :

struct _actor 
{ 
   ... 
};

typedef struct _actor _actor;
typedef struct _actor Actor; 

_actor. typedef struct _actor, _actor. C. :

  _actor myActor;

 struct _actor myActor;

++ , ++ , typedef.

typedef struct _actor, Actor. Actor, , .

, C- struct _actor , Actor . ++ , , typedefs . :

 struct Actor {.....}
 class  Actor {.....}

, , .

+4

3D- arduino hectop:

fpos_t SdBaseFile.h SdBaseFile.cpp , fpos_t1, .

0
source

Source: https://habr.com/ru/post/1766066/


All Articles