Class member pointer that can point to any datatype

The problem i am facing is for each of my three classes i need the pointers 'element' to point to a specific datatype for each different instances of the same class. All class instances will be stored together in vector arrays. Could someone please help point out what the hell is wrong with my code. This is for a school project so any help would be greatly appreciated.

I am trying to build a graphical user interface application using Openframeworks. Each section, object, and subobject represents an entity on the gui. The pointers 'element' are to point to the specific entity. Which is why i need the pointer for each different instance of the classes to be of a specific datatype using templates. Sorry if any parts of my code does not make sense but i am new to templates.

The first header file

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
46
47
48
49
50
51
52
53
//GUI Section

#ifndef GUI_SECTION
#define GUI_SECTION

#include <string>
#include <vector>

#include "gui_object.h"

using namespace std;

template <class T>
class gui_section
{
	public:

		gui_section();

		gui_section( string );

		~gui_section();

		void update();

		void draw();

		T * element;

		vector<gui_object> object;

		void instantiate_element();

		void reset_element();

		void set_array_pos( int& );

		bool element_isInstantiated();

	private:

		//General
		string name;

		//Operation
		unsigned int section_array_pos;

		//Status
		bool element_instantiated;
};

#endif


The next header file...

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
46
47
48
49
50
51
52
53
//GUI Object

#ifndef GUI_OBJECT
#define GUI_OBJECT

#include <string>
#include <vector>

#include "gui_subobject.h"

using namespace std;

template <class T>
class gui_object
{
	public:

		gui_object();

		gui_object( string );

		~gui_object();

		void update();

		void draw();

		T * element;

		vector<gui_subobject> subobject;

		void instantiate_element();

		void reset_element();

		void set_array_pos( int&, int& );

		bool element_isInstantiated();

	private:

		//General
		string name;

		//Operation
		unsigned int section_array_pos;
		unsigned int object_array_pos;

		//Status
		bool element_instantiated;
};

#endif 


The last header file...

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
46
47
48
49
50
//GUI Subobject

#ifndef GUI_SUBOBJECT
#define GUI_SUBOBJECT

#include <string>
#include <vector>

using namespace std;

template <class T>
class gui_subobject
{
	public:

		gui_subobject();

		gui_subobject( string );

		~gui_subobject();

		void update();

		void draw();

		T * element;

		void instantiate_element();

		void reset_element();

		void set_array_pos( int&, int&, int& );

		bool element_isInstantiated();

	private:

		//General
		string name;

		//Operation
		unsigned int section_array_pos;
		unsigned int object_array_pos;
		unsigned int subobject_array_pos;

		//Status
		bool element_instantiated;
};

#endif 
Topic archived. No new replies allowed.