RE: visual c++ upgrading problem

Posted by cuchulainn on
URL: http://quantlib.414.s1.nabble.com/visual-c-upgrading-problem-tp3536p3551.html

Re: [Quantlib-users] visual c++ upgrading problem
 
MersenneTwisterUniformRng twister;
BoxMullerGaussianRng<MersenneTwisterUniformRng> generator( twister );


I think you must still write the default constructor as well, I think. In VS 2005 you mustd define def. con.
 
Hope this helps
 
Daniel

 

From: [hidden email] on behalf of Luigi Ballabio
Sent: Mon 24/01/2005 16:39
To: Luca Berardi
Cc: [hidden email]
Subject: Re: [Quantlib-users] visual c++ upgrading problem

On 01/24/05 16:13:00, Luca Berardi wrote:


>
> The piece of code:
>
> BoxMullerGaussianRng<MersenneTwisterUniformRng>
>    generator( MersenneTwisterUniformRng() );
> Z = generator.next().value;
>
> generates the following error:
>
> left of '.next' must have class/struct/union type
> type is 'overloaded-function'

Luca,
        you've been bitten by the infamous "C++ most vexing parse." The 
compiler parses the first statement as the declaration of a function called 
'generator' which returns a BoxMuller<MersenneTwister> and takes as 
argument a function with no arguments and returning a MersenneTwister (yes, 
it can be parsed this way. And yes, for some reason the C++ standard 
_requires_ it to be parsed this way. Most vexing indeed.)


> When compiling the same piece of code with Visual C++ 6.0 I didn't get 
> any errors

VC6 didn't follow the C++ standard :)

You can fix the code by rephrasing the variable declaration so that it 
can't be parsed as a function. Something like

MersenneTwisterUniformRng twister;
BoxMullerGaussianRng<MersenneTwisterUniformRng> generator( twister );

should work.

Later,
        Luigi




-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Quantlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users