MessageWarren, Appreciate the detailed info you have provided.
Regards. ----- Original Message ----- From: Warren Vick, Europa Technologies Ltd. To: 'Phil Waight' Cc: [EMAIL PROTECTED] Sent: Friday, November 19, 2004 7:24 PM Subject: RE: MI-L Re: RE:MI-L Off-topic: c++ porting problem- gnu c++ to MS .net c++ Hello Phil,. I think I can help you with the second part of your query. The error is actually quite a good one but the reason why the warning is produced needs a little background information on how C++ implements OOP. The error is generated because your class has members that are pointers... distance, depotdist and name. Obviously these are assigned or allocated space somewhere in your class methods. The problem is, however, that you do not have a copy constructor or assignment operator method (these are the two the warning complains about). So, with the absence of these, when you construct a copy, or assign, an object of class Gene, a binary copy of the object is made in memory. The danger here is that the pointer values will be copied to the new object and you will end up with two objects which internally have pointers directed to the same space. i.e. change one and the other will change too. This is generally, but not always, undesirable and could cause some nasty bugs which are difficult to track down. The solution is to always have a copy constructor and assignment operation function is your classes. It's generally good OOP practice. As for a dummy's guide to the errors, I'm afraid it's just a case of experience. If it was easy, C++ development wouldn't be regarded as a value skill! Regards, Warren Vick Europa Technologies Ltd. http://www.europa-tech.com -----Original Message----- From: Phil Waight [mailto:[EMAIL PROTECTED] Sent: 19 November 2004 04:45 To: David Langley Cc: [EMAIL PROTECTED] Subject: MI-L Re: RE:MI-L Off-topic: c++ porting problem- gnu c++ to MS .net c++ 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 ----- From: David Langley To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] 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 ***
