Thread: Syntax Help Please

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    719

    Syntax Help Please

    I'm playing around with genetic algorithms, and like always, i'm trying to templatize part of it. Although I'll probably abandon this code because I don't like where it's going, I'm still curious as to how I can get it to compile.

    The problem I'm having is passing the template argument to "float fitness_score(Chromo<>:naType)". As is, i get the error:

    37 C:\compilers\bloodshed\main.cpp invalid conversion from `float (*)(Chromo<32>:naType)' to `float (*)(Chromo<16>:naType)'

    I've tried just about all I know, but I can't seem to get it to compile.

    Code:
    #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    
    
    template<int FieldSize = 32>
    class Chromo
    {
    	public:
    	struct DnaType{	unsigned dt_dna: FieldSize;	};
    
    	Chromo(void) : geneCount(FieldSize){}
    	Chromo(const Chromo<> &s) : geneCount(s.geneCount)
    		{dna = s.dna;}
    	
    	float score(float (*sc)(DnaType));
    
    	private:
    	unsigned dna : FieldSize;
    	const int geneCount;		
    };
    
    
    float fitness_score(Chromo<>::DnaType dt)
    {
          //dummy function
          return 1.2f;
    }
    
    int main(int argc, char *argv[])
    {
        const int x = 16;
        Chromo<x> ccc;          
           
        cout << ccc.score(fitness_score) << endl;
          
        system("PAUSE");    //dev-c++ generated
        return EXIT_SUCCESS;
    }
    Any ideas?
    Last edited by misplaced; 04-22-2005 at 03:05 AM.
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM