what's wrong with my class?

What's wrong with my (unfinished) class?
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
class level : public texture
{
	protected:
		uint8_t* bounds = new uint8_t[4][64];
		int size;
	public:
		level() {}
		void loadBounds(char* filename)
		{
			//Open file
			std::ifstream input{filename, ios::binary};
			if (input)
			{
				cout << "Failed to load bounds file\n";
				return;
			}

			//Find size
			input.seekg(0, ios::end);
			size = input.tellg();
			if (size>64)
			{
				cout << "Bounds file too big\n";
				return;
			}
			input.seekg(0, ios::beg);
		}
		level(char* filename) {loadBounds(filename);}
		uint8_t* grabBounds() {return bounds;}
};

it causes these errors:
classes.h: At global scope:
classes.h:63:39: error: cannot convert ‘uint8_t (*)[64] {aka unsigned char (*)[64]}’ to ‘uint8_t** {aka unsigned char**}’ in initialization
uint8_t** bounds = new uint8_t[4][64];
^
classes.h: In member function ‘uint8_t* level::grabBounds()’:
classes.h:88:33: error: cannot convert ‘uint8_t** {aka unsigned char**}’ to ‘uint8_t* {aka unsigned char*}’ in return
uint8_t* grabBounds() {return bounds;}
^~~~~~
1
2
3
4
5
6
7
8
9
10
11
12
class level
{
    public:
       using bounds_type = std::uint8_t[64][4] ;
                           // or better: std::array< std::array< std::uint8_t, 64 >, 4 > ;

    private: bounds_type bounds {} ;

    public:
        const bounds_type& grab_bounds() const { return bounds ; } // return reference to array
        // ...
};
thanks that worked
Topic archived. No new replies allowed.