Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compiler Error with Nested Classes as Friends

Status
Not open for further replies.

sadOldMan

Programmer
May 14, 2003
2
GB
I Get the following error with Visual C++ 6. Is this a bug with the compiler and is there a work around?

d:\my documents\visual studio projects\mylib\lib.h(16) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1794)

Here's the class definition: Lib.h

Code:
#ifndef MYLIB_H
#define MYLIB_H

class Hen {
 public:
  Hen();
  void Display(void);
  class Nest;
  friend class Nest;
  class Nest {
    public:
      Nest();
      void Display(void);	
      class Egg();
      friend class Egg();
      class Egg {
       public:
	Egg();
	void Display(void);
      private:
        string colour;
     };
   private:
    string colour;
  };
 private:
   string colour;
};
#endif
 
Oh dear I'm half asleep this morning.

Where did those naughty brackets come from around the second class declaration? Don't seem to be able to delete this thread.
 
Oh dear
That was great! :) Welcome to Tek-Tips [cheers]

No one can directly delete posts or threads. The forum moderators do that. You can ask them to delete the thread for you by clicking the Inappropriate post? If so, Red Flag it! link. If you want the entire thread deleted click that link for the original post in the thread.

-pete
I just can't seem to get back my IntelliSense
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top