TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: CHRISTIAN S. PEDERSEN
from: HERBERT BUSHONG
date: 1997-07-25 04:39:00
subject: Mutually class definition

::> I want to define two classes like the following:
/* you need a forward declaration of class B */
class B;
::> class A
::> {
::>    A(int a) {  };
::>    B func1() { return B(1); };
::> }
::> class B
::> {
::>   B(int a) {  };
::>   A func2() { return A(1); };
::> }
::> two classes which each contains a function which return a instance of the
::> class. I get a "typename expected"-error in class A. I believe I have to 

::> the "typename" keyword, but I can't get it to work.
Add the forward declaration before class A, so that it knows there *is* a 
class B...
#  Herbert Bushong    harchon@centuryinter.net       [TEAM OS/2]    
-  Blackbeard's BBS   Intelec: 239:600/0            
+  Fido: 1:19/19      http://www.intelec.com/software/
---
   RM 1.31 2508   Taglines are like cats. You just THINK they're yours.
---------------
* Origin: Blackbeard's BBS - Ville Platte, LA - 318-468-3385 (1:19/19)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.