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.
----- Original Message -----
Sent: Friday, November 19, 2004 9:31 AM
Subject: RE:MI-L Off-topic: c++ porting problem- gnu c++ to MS .net c++

Phill,

try using a typedef (a synonym for another type) declaration as a pointer to
the Chromo vector

i.e

typedef Chromo* pChromo ;

then change your code to
pChromo *myChromoPool ; // Chromosome vector
myChromoPool = new (pChromo)[popSize]  ;

Not sure about the second problem as I would have to see the header file.

Best Regards,

Dave

David P. Langley
Director of Programming Services

Mapping Solutions, LLC
4660 S. Hagadorn Rd.
Suite 120
East Lansing, MI 48823
USA

Voice: (+1) 517-332-7735
Cell:  (+1) 517-402-3238
Fax:   (+1) 517-332-1329

Email: [EMAIL PROTECTED]
SMS:  5174023238 (@tmomail.net)

Visit our website: www.mappingsolutions.com

*** Need inexpensive GDT and NavTech street-level data for North America and
Europe? Check out Map-In-A-Box at http://www.mapinabox.com ***
*** Map-In-A-Box Year-End Blowout!... Map-In-A-Box is on Sale Until December
31, 2004.. Check out Map-In-A-Box at http://www.mapinabox.com ***

// 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

Reply via email to