Class member is undefined ?! how??

hi, I have comented out last 4 lines where problem is (into file "Linija.cpp")
rest of the code is OK.


Linija.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#pragma once
class Linija {
private:
	int x1, y1, x2, y2;
	void OdreziTocku(int Linija::* pok1, int Linija::* pok2, int v1, int v2, int p, int tip);
public:
	Linija();
	Linija(int px1, int px2, int py1, int py2);
	~Linija();
	void setX1(int x);
	void setX2(int x);
	void setY1(int y);
	void setY2(int y);
	int getX1() const;
	int getX2() const;
	int getY1() const;
	int getY2() const;
	void Odrezi(int px1, int py1, int px2, int py2);
};


Linija.cpp (function definitions)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "Linija.h"

Linija::Linija(int px1, int px2, int py1, int py2) : x1(px1), x2(px2), y1(py1), y2(py2) {}
Linija::~Linija() {}
void Linija::Odrezi(int px1, int py1, int px2, int py2) {
	OdreziTocku(&Linija::x1, &Linija::y1, x2 - x1, y2 -y1, px1, 1);
	OdreziTocku(&Linija::x1, &Linija::y1, x2 - x1, y2 -y1, px2, 0);
	OdreziTocku(&Linija::y1, &Linija::x1, y2 - y1, x2 -x1, py1, 1);
	OdreziTocku(&Linija::y1, &Linija::x1, y2 - y1, x2 -x1, py2, 0);
	OdreziTocku(&Linija::x2, &Linija::y2, x1 - x2, y1 -y2, px1, 1);
	OdreziTocku(&Linija::x2, &Linija::y2, x1 - x2, y1 -y2, px2, 0);
	OdreziTocku(&Linija::y2, &Linija::x2, y1 - y2, x1 -x2, py1, 1);
	OdreziTocku(&Linija::y2, &Linija::x2, y1 - y2, x1 -x2, py2, 0);
}
void Linija::OdreziTocku(int Linija::*pok1, int Linija::*pok2, int v1, int v2, int p, int tip) {
	if((this->*pok1 < p && tip) || (this->*pok2 > p && !tip)) {
		double param = (p - this->*pok1) / static_cast<double>(v1);
		if((param > 0 && tip) || (param < 1 && !tip)) {
			this->*pok2 = this->*pok2 + static_cast<int>(param * v2 + 0.5);
			this->*pok1 = p;
		}
		else
			this->*pok1 = this->*pok2 = -1;
	}
}
inline int Linija::getX1() const {return x1;}
inline int Linija::getX2() const {return x2;}
inline int Linija::getY1() const {return y1;}
inline int Linija::getY2() const {return y2;}
inline void setX1(int x) {x1 = x;}  /*here it says x1 undefined*/
inline void setX2(int x) {x2 = x;}  /*here to*/
inline void setY1(int y) {y1 = y;}  /*here to*/
inline void setY2(int y) {y2 = y;}  /*here to*/


x1,x2,y1,y2 are defined lol.
Are you missing some Linija:: ?

Last edited on
O my f* god.
I use my glasses whenever I can, and this time I obviously didn't,
can't belive I was so blind :D

tnx for help!!
Topic archived. No new replies allowed.