CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2008
    Posts
    18

    Code can't find previously defined class

    I have a file that has several class delcarations in it. It looks like
    Code:
    class A : public B
    {
    public:
      virtual int call (void)
      {
        stuff;
        return -1;
      }
    };
    
    class C : public D, private E
    {
      stuff;
    };
    
    int C::foo(void)
    {
     A *req;
     return 0;
    }
    When I try to compile, at "A *req" I get identifier "req" is undefined. But req isn't the identifier, A is. So it looks like it can't find A. But why wouldn't it find it. It's in the same file.
    Last edited by homer_3; July 21st, 2009 at 02:59 PM.

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Code can't find previously defined class

    Did you forget to put the semicolon on the end of class C?

  3. #3
    Join Date
    Nov 2008
    Posts
    18

    Re: Code can't find previously defined class

    No, sorry. That was just a typo. I fixed it in the edit.

  4. #4
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Code can't find previously defined class

    Post the smallest and simplest program that demonstrates the error. Also, post the exact error message.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  5. #5
    Join Date
    Jan 2009
    Posts
    1,689

    Re: Code can't find previously defined class

    Where are D and E? Is this all one file, or did you forget to include something.. or have circular references. Circular references are the hardest to find.

  6. #6
    Join Date
    Nov 2008
    Posts
    18

    Re: Code can't find previously defined class

    I've given up on this error. I was getting it while compiling ACE. From everything I see, it should be compiling fine. But the error was coming from an examples folder, so it's not core code. So I just commented out the refernce to the makefile that compiles the file giving the error and continued on. The only thing I can think of is it is an issue with my compiler.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured