[galib] Still can't get generation count inside Objective function

Matthew Wall mbwall at MIT.EDU
Mon Oct 25 06:23:48 EDT 2010


On 25 Oct 2010, at 02:01, Everardo Robredo wrote:

> Hi,
>
> Thank you for that quick answer. I tried what you suggested but I keep
> getting the following errors:
>
> /usr/include/ga/GAGenome.h: In function ‘float Objective(GAGenome&)’:
> /usr/include/ga/GAGenome.h:264: error: ‘GAGeneticAlgorithm*
> GAGenome::ga’ is protected
> genetic_fann.cpp:94: error: within this context
> genetic_fann.cpp:94: error: ‘g->GAGenome::ga’ cannot be used as a  
> function
> make: *** [OBJ.x86_64-unknown-linux-gnu/genetic_fann.o] Error 1
>
> This is the code:
>

...

>  GAGeneticAlgorithm* gal = g.ga();

use the accessor method rather than the data element itself:

   GAGeneticAlgorithm* gal = ga.geneticAlgorithm();

no need to modify the headers.

m





More information about the galib mailing list