TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: CHRISTIAN S. PEDERSEN
from: FRANOIS DE MEY
date: 1997-07-28 03:03:00
subject: Mutually class definition.

Hi coder... 
 
 CSP> class A
 CSP> {
 CSP> A(int a) {  };
 CSP> B func1() { return B(1); };
 CSP> }
 CSP> class B
 CSP> {
 CSP> B(int a) {  };
 CSP> A func2() { return A(1); };
 CSP> }
 CSP> two classes which each contains a function which return a instance of
 CSP> the other class. I get a "typename expected"-error in class A. I
 CSP> believe I have to use the "typename" keyword, but I can't get it to
 CSP> work. 
 I cannot be exactly sure, but I suppose, when U enter 'return B(1);',
 he don't know a variable or a function called B(1), this fct is in a class,
 but B::B(1) can't be called out of B class.
 If I had to enter this code, I would have done as this :
 class A {
  A(int a) { reinit(a) };
  void reinit(int a) {  };
  void func1( B *Ptr ) { Ptr->reinit(1) };
 }
 class B {
  B(int a) { reinit(a) };
  void reinit(int a) {  };
  void func1( A *Ptr ) { Ptr->reinit(1) };
 }
 Ciao
                        Ÿäâ
   
   -I hope it will be useful 2 U.-
... Coding is so funny...
--- Blue Wave/DOS v2.30 [NR]
---------------
* Origin: Programmer's Paradise -Belgium- 32-10-813088 (2:293/2009)

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™.