Original Post
Hello peoples! I've run into a brick wall. See, I wanted to make a function that created an instance of a class... and then returned it so I could use it later. This is what I got:
class Image {
public:
pvr_ptr_t img;
int w;
int h;
};
Image* LoadImage(const char* file, int width, int height)
{
//Create instance
Image* ImageName = new Image;
ImageName.img = pvr_mem_malloc(width*height*2);
ImageName.w = width;
ImageName.h = height;
png_to_texture(file, ImageName.img, PNG_FULL_ALPHA);
return ImageName;
}
And I called it like so:
Image* p_Room = LoadImage("/rd/room.png",256,256);
But this is what VC++ 6.0 shot at me.
In file included from ChainSawR5.cpp:20:
Image.cpp: In function `Image* LoadImage(const char*, int, int)':
Image.cpp:14: request for member `img' in `ImageName', which is of
non-aggregate type `Image*'
Image.cpp:15: request for member `w' in `ImageName', which is of non-aggregate
type `Image*'
Image.cpp:16: request for member `h' in `ImageName', which is of non-aggregate
type `Image*'
Image.cpp:17: request for member `img' in `ImageName', which is of
non-aggregate type `Image*'
NMAKE : fatal error U1077: 'C:\DevKitDC\bin\g++.exe' : return code '0x1'
Stop.
Error executing NMAKE.
ChainSawR5.exe - 1 error(s), 1 warning(s)
Did I make it clear what I'm tring to do? Any help on this is greatly appreciated.