mam taki kod
// Genetic.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "population.h"
int _tmain(int argc, _TCHAR* argv[])
{
//
//path to clients file
//
char * path;
path = "H:\\gen001.TXT";
readInput(path, title, noCar, carCapacity, noClients);
//
//create distance table
//
float distance;
int roznicaX, roznicaY;
Cord Z,Do;
tabDistance = new float * [noClients-1];
for(int i = 0; i < noClient-1; i++)
{
tabDistance[i] = new float [noClient-1-i];
for(int j = i+1; j < noClient; j++)
{
Z = genoClt[i].getClnPos();
Do = genoClt[j].getClnPos();
if( Z.x <= Do.x)roznicaX = Do.x - Z.x;
else roznicaX = Z.x - Do.x;
if( Z.y <= Do.y)roznicaY = Do.y - Z.y;
else roznicaX = Z.y - Do.y;
tabDistance[i][j] = sqrt( roznicaX*roznicaY );
}
}
//
//fin
//
return 0;
}
i teraz utworzylem sobie osobny plik populacja w ktorym zamiescilem dodatkowe globalne zmienne i funkcje
#ifndef __POPUL_H__
#define __POPUL_H__
#include <stdio.h>
#include <math.h>
#include "Gen.h"
//
//global func and variables
//
char title[50];
int noCar,
carCapacity,
noClients;
Gen * genoClt; //each gen in table has his own number
float ** tabDistance; //distance table
float getDistance(int Z, int Do);
//
void readInput(char * path,char * title, int &noCar, int &cCapacity, int &noClient);
#endif
i teraz przy budowaniu genetic.cpp mowi mi ze
title, noCar, carCapacity, noClients; genoClt , tabDistance; sa juz zdefiniowane w Genetic.obj
no i nie wiem zabardzo gdzie jest blad!! pragma once nie pomaga wcale!! nie wiem moze to wina edytora i nie zapisuje zmian!bo przedtem te zmienne byly w genetic.cpp ;/ no ale sprawdzalem to an 5 roznych sposobow i raczej jest ok!!
edit 12.10.2005:wpadkowalem wszystko z population.h i.cpp do gentic.cpp i dziala ale nie rozumiem czemu nie chcialo zaakceptowac poprzedniego rozwiazania!