www.digitalmars.com         C & C++   DMDScript  

c++.dos - Help me!

reply "ZaitcevE.V." <Genior km.ru> writes:
Why that following fragment of the program gives mistake of compilation for
.cpp:

struct  defmen
    {
    struct kmen
        {
        struct defmen *men;
        short   int    *mkeyout;
        }
    *mnext;
    char   *mstr;
    };

void
main(int argc, char **argv)
    {
    struct kmen *text;

    text->men[0].mstr;
    }

L:\ZAICEV\MED\PROJ\MARS>sc  test.cpp -ml
    text->men[0].mstr;
             ^
test.cpp(20) : Error: 'men' is not a member of undefined class 'kmen
    text->men[0].mstr;

And for .C all is compiled normally!  In VC 1.0 too all O'k.  How to bypass
this problem?
Jan 09 2002
parent "Walter" <walter digitalmars.com> writes:
kmen is nested inside defmen. You defined a new defmen class at global scope
with the declaration of text. The solution is to move the definition of
struct kmen into the global scope. -Walter

"ZaitcevE.V." <Genior km.ru> wrote in message
news:a1jima$2jjg$1 digitaldaemon.com...
 Why that following fragment of the program gives mistake of compilation

 .cpp:

 struct  defmen
     {
     struct kmen
         {
         struct defmen *men;
         short   int    *mkeyout;
         }
     *mnext;
     char   *mstr;
     };

 void
 main(int argc, char **argv)
     {
     struct kmen *text;

     text->men[0].mstr;
     }

 L:\ZAICEV\MED\PROJ\MARS>sc  test.cpp -ml
     text->men[0].mstr;
              ^
 test.cpp(20) : Error: 'men' is not a member of undefined class 'kmen
     text->men[0].mstr;

 And for .C all is compiled normally!  In VC 1.0 too all O'k.  How to

 this problem?

Jan 10 2002