[galib] GA1DArrayGenome
Andre Baumgart
andre.baumgart at ti.uni-mannheim.de
Tue Aug 10 04:01:26 EDT 2004
Hi
I tried to use the GA1DArrayGenome with my own Type Point.
GA1DArrayGenome<Point> genome(20);
According to the documentation the Point class should have included
definitions of the operator !=, == , = and the copy constructor. Below
are the gcc error output and the class definition.
Thanx in advance if anybody has an idea how this can be solved.
Andre
----------------------------------------------------------------
class Point: The operators are defined only dummy!
class Point {
protected:
float _x, _y, _z;
public:
Point(){ }
Point(int i){}
Point(float x, float y, float z) { _x = x; _y = y; _z = z; }
Point(const Point & p) { _x = p._x; _y = p._y; _z = p._z; }
Point & operator =(const Point & p) { return *this; }
int operator ==(const Point & p) { return 0; }
int operator !=(const Point & p) { return 0; }
~Point() {}
float x() const { return _x; }
float y() const { return _y; }
float z() const { return _z; }
float x(float val) { return _x=val; }
float y(float val) { return _y=val; }
float z(float val) { return _z=val; }
friend ostream & operator<<(ostream & os, const Point & p){
os << "(" << p._x << ", " << p._y << ", " << p._z << ")";
return os;
}
};
--------------------------------
gcc messages:
(OSSPx_SteadyStateGA.cpp is the file where the GA1DArrayGenome is called!)
g++ -I/usr/include -I/usr/include/g++-3 -O0 -Wall -g -c
-fmessage-length=0 -Wno-deprecated -O -fexceptions
-oOSSP/OSSPx_SteadyStateGA.o ../OSSP/OSSPx_SteadyStateGA.cpp
/usr/local/include/ga/GA1DArrayGenome.C: In static member function
`static float GA1DArrayGenome<T>::ElementComparator(const GAGenome&,
const GAGenome&) [with T = Point]':
/usr/local/include/ga/GA1DArrayGenome.C:49: instantiated from
`GA1DArrayGenome<T>::GA1DArrayGenome(unsigned int, float (*)(GAGenome&),
void*) [with T = Point]'
../OSSP/OSSPx_SteadyStateGA.cpp:102: instantiated from here
/usr/local/include/ga/GA1DArrayGenome.C:452: error: passing `const
Point' as `this' argument of `int Point::operator==(const Point&)'
discards qualifiers
-----------------------
More information about the galib
mailing list