[C++-sig] Re: Cross module definition
David Abrahams
dave at boost-consulting.com
Wed Sep 3 15:01:48 CEST 2003
"Arnaud PICARD" <arnaud.picard at edfgdf.fr> writes:
> Sorry, my latest mail was sent before I'd had time to complete it...
> --------------------------
>
> Hello,
>
> As I've already mentionned, I still have problems with cross def.
> Here you'll find an example I've used to test a method. I'm not sure I've
> done it right (actually I guess it's false since I can't get it to work
> properly)
>
> So, in these modules, I have define one as ModuleA and the other as
> ModuleB.
> They are AFAIK well written.
>
> If I import them under python, and define a = ModuleA.Cmplx( 1., 0. ), b =
> ModuleB.Printer(), and then try b.print1( a ) or b.print2( a ) it won't
> work.
> If I define a with ModuleB instead of ModuleA it's running. That's still
> the same problem I had with cross-module definition, with an example... If
> I remove the line define_Cmplx() from ModuleD definition, I still cannot
> get it to work even though I've imported first ModuleA then ModuleB.
>
> What do I have to do so that I can pull the line "define_Cmplx()" out of my
> ModuleB definition so that ModuleB's methods recognize my class Cmplx ?
> I've understood what was reponsded last time, but I have not been able to
> have it work properly...
Well, a real complete example that actually compiles on a conforming
C++ compiler and includes the precise Python code to execute would be
a big help in being sure that I was reproducing your case precisely,
but after massageing your code so it would compile (changed
<iostream.h> to <iostream>, added "using namespace std;", removed
define_Cmplx() from ModuleB) I get:
1 + 0 i
1 + 0 i
For both b.print1(a) and b.print2(a). On my compilers.
Which compiler and platform are you using?
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list