From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30261 invoked by alias); 11 Jun 2008 11:19:04 -0000 Received: (qmail 30252 invoked by uid 22791); 11 Jun 2008 11:19:04 -0000 X-Spam-Check-By: sourceware.org Received: from flox.kiam1.rssi.ru (HELO flox.kiam1.rssi.ru) (193.232.219.11) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 11 Jun 2008 11:18:44 +0000 Received: (from urik@localhost) by flox.kiam1.rssi.ru (8.11.3/8.11.3) id m5BBIdT05367 for gcc-help@gcc.gnu.org; Wed, 11 Jun 2008 15:18:39 +0400 (MSD) (envelope-from urik) Date: Wed, 11 Jun 2008 11:19:00 -0000 From: Kalugsky Uriy Message-Id: <200806111118.m5BBIdT05367@flox.kiam1.rssi.ru> To: gcc-help@gcc.gnu.org Subject: FRIEND_CLASS_TYPEDEF Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-06/txt/msg00114.txt.bz2 Hello, GCC4.1.0 can't compile the code below. It doesn't like the line 'friend class TYPEDEFED_A'. Could you explane , please, why. Best regards, Yuri ================================== The operating system - Gnu/Linux ================================== GCC Version ============================= g++ (GCC) 4.1.0 (SUSE Linux) ============================= The code to compile =================== #include #include using namespace std ; class B ; class A { public : A(void) {} ~A(void) {} void PutInOut(B const &inst) ; } ; typedef A TYPEDEFED_A ; class B { /////////////////////////////////////////////// friend class TYPEDEFED_A ; ////////////////////////////////////////////// public : B(void): a(777) {} ~B(void){} private : int a ; } ; void TYPEDEFED_A::PutInOut(B const &inst) { cout <<"\nB.a " << inst.a << endl ; } int main (int argc, char const *argv[]) { B b_buf ; TYPEDEFED_A a_buf ; a_buf.PutInOut(b_buf) ; return 0 ; } Command line ============= g++ -Wall -O -o ./class_typedef ./class_typedef.cpp The compiler messages ======================== ./class_typedef.cpp:19: error: using typedef-name 'TYPEDEFED_A' after 'class' ./class_typedef.cpp:15: error: 'TYPEDEFED_A' has a previous declaration here ./class_typedef.cpp:19: error: friend declaration does not name a class or function ./class_typedef.cpp: In member function 'void A::PutInOut(const B&)': ./class_typedef.cpp:26: error: 'int B::a' is private ./class_typedef.cpp:31: error: within this context