Dziedziczenie, konstruktor

0

Witam, mam pewien problem, kompilator ignoruje podawane przeze mnie wartości w czasie tworzenia zmiennej i tworzy ją za pomocą konstruktora domyślnego, nie mam pojęcia dlaczego. Pomocy

 
class cScena {
public:
	void dodajO(float x, float y, float r);
	vector<cFigura*> tab;
	void rysuj();
	void init();
	void klawisz(unsigned char key, int x, int y);
	void mysz(int button, int state, int x, int y);
};
class cFigura
{
protected:
	float x, y;

public:
	cFigura();
	virtual void rysuj() = 0;
};
class cOkrag
	:public cFigura
{
	float r;
public:
	cOkrag();
	cOkrag(float _x, float _y, float _r);
	virtual void rysuj();
};
//------------------------------------------
void cOkrag::rysuj() {
	glPushMatrix();
	glColor3f(1.0, 1.0, 1.0);
	glTranslatef(0, 0, 0);
	glBegin(GL_POLYGON);
	for (float kat = 0; kat < 360; kat += 5)
	{
		GLfloat _x, _y;
		_x = r*cos(kat / 180 * 3.14);
		_y = r*sin(kat / 180 * 3.14);
		glVertex2f(_x, _y);
	}
	glEnd();
	glPopMatrix();
	glFlush();
}
cOkrag::cOkrag()
{
	x=0; y=0;
	r=0.2;
}
//cOkrag::cOkrag() : r(0.2) {}
cOkrag::cOkrag(float _x, float _y, float _r)  {
	x = _x;
	y = _y;
	r = _r;
}
cFigura::cFigura()
{
	x = -0.5; y = -0.5;
}
//------------
cScena scena;
void rysuj()
{
	scena.rysuj();
}
int main(int argc, char* argv[])
	scena.tab.push_back(&PL);
	cOkrag okr(0.9,-0.5,0.5);
	scena.tab.push_back(&okr);
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutInitWindowSize(500,500);
	glutInitWindowPosition(0, 0);
	glutCreateWindow("simple");
	glutDisplayFunc(rysuj);
	glutMouseFunc(Mysz);
	glutKeyboardFunc(klawisz);// klawisz musi byc funkcja, nie moze byc metoda
	scena.init();
	glutMainLoop();
	system("pause");
	return 0;
}
2

Chyba źle pociąłeś kod, bo to:

    kat = 0;
    R=0.5; G=0.5; B=0.5; 

powinno wywalić błąd kompmilacji.</del> Więcej kodu, pokaż fragment gdzie nie działa tak jak chcesz.

1 użytkowników online, w tym zalogowanych: 0, gości: 1