home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,024 of 33,346   
   Pete Becker to VladislavKurmaz   
   Re: Base class as friend for derived   
   18 Mar 12 07:42:11   
   
   39ee1b68   
   From: pete@versatilecoding.com   
      
   On 2012-03-18 12:07:12 +0000, VladislavKurmaz said:   
      
   > Hi.   
   > Here is minimal example, that tries to declare base class as friend   
   > for derived.   
   >   
   > template    
   > class base   
   > {   
   > };   
   >   
   > class derived : public base< derived >   
   > {   
   > 	template < class U > friend class base;   
   > };   
   >   
   > msvc11/msvc10/msvc9/Comeau-online process this code withou any errors   
   > or warnings, but gcc-4.5.3(cygwin) : generate next message "error:   
   > specialization of 'base' after instantiation"   
   >   
   > Is it correct code from C++ standard perspective?   
      
   I don't know, but let me see if I can avoid the issue.   
      
   Does every instantiation of base need to be a friend of derived?   
   This seems like overkill. Or is the goal actually to make base   
   a friend of derived? If it's the latter, the way to do it is to just   
   write it in the obvious way:   
      
   class derived : public base   
   {   
   	friend base;   
   };   
      
   --   
      Pete   
   Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The   
   Standard C++ Library Extensions: a Tutorial and Reference   
   (www.petebecker.com/tr1book)   
      
      
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca