|
Dave,
That change made the code more
readable and pointed me in the right direction. I tried the -pedantic
switch in gcc.
"chromo.cc:15: error: ISO C++ forbids array
dimensions with parenthesized type in new"
So:
myChromoPool = new pChromo
[popSize];
now works in VS.
Thanks for the help. I have attached the header
file for the other problem if you're able to look at that.
Phil.
|
// gene.h // Declaration of class Gene // Thomas Pederson, 950505 #ifndef GENE #define GENE
#include "global.h"
//#include <stream.h>
#include <iostream>
//using namespace std;
class Gene
{
public:
Gene(char *_name, coord_t _x, coord_t _y,
unsigned int _index, unsigned int _distVecLength,
int _pointval, int _depotd); //v1.2
~Gene();
// Calculates Eucledian distance between this gene and _gene and returns the
value.
distance_t calculateDistanceTo(coord_t routed, Gene& _gene);
// store distance from this Gene to depot.
distance_t storeDepotDist(coord_t routed, int depotid);
// Returns Eucledian distance between this gene and _gene.
distance_t distanceTo(Gene& _gene);
// Returns this gene's index in original chromosome pool.
unsigned int getIndex() {return index;}
// Returns nearest depot.
unsigned int getNearestDepot() {return nearestdepot+1;}
// Returns this gene's name.
char *getName() {return name;}
// Returns this gene's depot counte.
int getDepotCnt() {return depotcnt;}
// Returns depot distance for this gene.
distance_t getDepotDist(int depotid) {return depotdist[depotid];}
// store distance from this Gene to depot.
distance_t getNearestDepotDist(Gene& _gene);
// Returns this gene's point value.
int getPointVal() {return pointval;}
// Prints gene information to stream.
friend std::ostream& operator<<(std::ostream& outStr, Gene& gene);
private:
distance_t *distance; // distance vector
distance_t *depotdist; // depot distance vector
unsigned int distVecLength; // length of distance vector
char *name; // name of gene
coord_t x,y; // gene's coordinates
unsigned int index; // gene's index
/* v 1.2 Add Depot distance array, Point value (-val = deliver, +val =
pickup) */
int depotcnt; // depot count from this point
int pointval; // action at point value eg. +3 = pickup 3 bins
int nearestdepot; // nearest depot on last check
};
#endif
--------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 14129
