I have this struct that has a constructor to initialize the values of its members. It doesn't seem to work, because when I output the values of it's members I get garbage. please tell me what is wrong with my code
Code:
#include <iostream>
using namespace std;
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;
typedef signed char s8;
typedef signed short s16;
typedef signed long s32;
struct object
{
s8 x, y;
u8 height, width, key;
object* next;
object(s8 X, s8 Y, u8 Width, u8 Height, u8 Key);
void report();
};
object::object(s8 X, s8 Y, u8 Width, u8 Height, u8 Key)
{
x = X;
y = Y;
width = Width;
height = Height;
key = Key;
}
void object::report()
{
cout << "x: " << x << endl;
cout << "y: " << y << endl;
cout << "width: " << width << endl;
cout << "height: " << height << endl;
cout << "key: " << key << endl;
}
int main()
{
bool screen[240][160];
for(int a = 0; a < 240; a++)
for(int b = 0; b < 160; b++)
screen[a][b];
object obstacle1(0, 0, 15, 15, 1);
object obstacle2(150, 100, 12, 12, 2);
object character(50, 50, 20, 20, 0);
obstacle1.report();
return 0;
}