Error unknown type vertices?? last few lines

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
34
35
36
37
38
39
40
41
42
43
44
45
#include <GL/glew.h>
#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <unistd.h>

GLuint texturediffuse, texturesphere, p;
float rotation; 
float height = 1.5;
float cam_offset =1.5;

class vertex_t{
	public:
	float x ,y ,z, u, v;
	class normal_t{
			float x,y,z;
	}normal;

};
class vertices_array{
	public:
		unsigned long len;
		unsigned long capacity;
		vertex_t ** nodes;
};
class face{
	public:
		vertex_t *p;
		vertex_t *q;
		vertex_t *r;
		class normal_t{
				float x,y,z;
		}normal;
};
class face_array{
	public:
		unsigned long len;
		unsigned long capacity;
		face ** nodes;
};
vertices_array vertices;
face_array faces;
vertices.len = 0;
faces.len= 0;


Last edited on
Hi,

First up, please always use code tags:
http://www.cplusplus.com/articles/z13hAqkS/

Some problems I can see:

* Global variables;
* Un-initialised global variables;
* No constructors - no way of initialising member pointers, one should provide a way of initialising all member variables;
* Be wary of what happens when implicit default constructors are invoked;
* Public data members in the classes - Either make it a struct which then is stored in some other container (itself a private member variable), or the data should be private, provide an interface of functions;
* Repetition of the normal_t class. Consider making this a class in it's own right, then use composition;
* Write a program with a main function, create objects there;
* Consider using STL containers rather than raw pointers, or at least use smart pointers. C++ has references, RVO, copy elision, move semantics so one doesn't need pointers as much as one might think.

Good Luck !!


Topic archived. No new replies allowed.