Object classes

Hello,

I am currently trying to create a class of objects(Triangles, Quads etc) that I can reuse in every project, but I seem to be overlooking some parts because I am getting a lot of errors.

This is the header for the objects:
#ifndef OBJECT_H
#define OBJECT_H

float x;
float y;
float z;

class Quad
{
private:
float m_glNormal3f(x, y, z);
float m_glTexCoord2f[4][2] = {}
float m_glVertex3f[4][3] = {};

Quad() {}

public:
Quad(float glNormal3f, float glTexCoord2f, float glVertex3f);

void SetValue(float glNormal3f, float glTexCoord2f, float glVertex3f);

float GetNormal() { return m_glNormal3f;}
float GetTexture() { return m_glTexCoord2f [4][2];}
float GetVertex() { return m_glVertex3f[4][3];}

};

#endif

This is the objects cpp:
#include “stdafx.h”
#include <iostream>
#include <stdlib.h>
#include <GL/glut.h>
#include “Object.h”

using namespace std;
Quad::Quad(float glNormal3f, float glTexCoord2f, float glVertex3f)
{
SetValue(float glNormal3f, float glTexCoord2f, float glVertex3f);
}

void Quad::(float glNormal3f, float glTexCoord2f, float glVertex3f)
{
m_glNormal3f=glNormal3f;
m_glTexCoord2f=glTexCoord2f;
m_glVertex3f=glVertex3f;
}

Waiting for suggestions,
Thx

Please use [ code][ /code] (without the space after ‘[’) around code snippets to improve readability.

If your code produces compiler errors those should tell you what the problem(s) are - since you did not post the errors it’s not possible to help with that.

Ok my mistake I’ll post the code again (i’ve made some changes and eliminated some errors).

Here is the code for the header Object:


#ifndef OBJECT_H
#define OBJECT_H


class Quad
{
private:
float m_glNormal3f[3];
float m_glTexCoord2f[4][2];
float m_glVertex3f[4][3];

public:
Quad() {}


	Quad(float glNormal3f[3], float glTexCoord2f[4][2], float glVertex3f[4][3]);

	void SetValue(float glNormal3f, float glTexCoord2f, float glVertex3f);

	float GetNormal() { return m_glNormal3f;}
	float GetTexture() { return m_glTexCoord2f;}
	float GetVertex() { return m_glVertex3f;}
};

#endif

And here is the code for the Object cpp:




#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include <GL/glut.h>
#include "Object.h"

using namespace std;
Quad::Quad(float glNormal3f[3], float glTexCoord2f[4][2], float glVertex3f[4][3])
{
	SetValue(glNormal3f[3], glTexCoord2f[4][2], glVertex3f[4][3]);
}

void Quad::SetValue(float glNormal3f[3], float glTexCoord2f[4][2], float glVertex3f[4][3])
{
	m_glNormal3f=glNormal3f[3];
	m_glTexCoord2f=glTexCoord2f[4][2];
	m_glVertex3f=glVertex3f[4][3];
}


And here is a code snippet from my main function (light.cpp) I took only the part that generates errors:



glBegin(GL_QUADS);

//Bottom

Quad cQuad;
cQuad.GetNormal (0.0, 1.0, 0.0);
cQuad.GetTexture (0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0);
cQuad.GetVertex (-2.5, -2.5, 2.5, 2.5, -2.5, 2.5, 2.5, -2.5, -2.5,-2.5, -2.5, -2.5); 

glEnd();


Currently I receive the following errors:
error C2440: ‘return’ : cannot convert from ‘float [3]’ to ‘float’

The above error occurs for all the float variables.

error C2511: ‘void Quad::SetValue(float [],float [][2],float [][3])’ : overloaded member function not found in ‘Quad’

The above error is generated by Object.cpp

error C2660: ‘Quad::GetNormal’ : function does not take 3 arguments

The above error is generated by light.cpp (my main function) and occurs for every class member in the snippet.

Thx.

http://www.learncpp.com/

Yep allready know the site that’s where I started to learn c++. Any other suggestions that I should take into consideration?