psycorpse
February 24th, 2008, 01:04 PM
I am pretty novice when it comes to C++ however I have take the basic courses at the community college as well as oo programming with C++. I am trying to write something that has been written about 3 million times. I am writing a class to read to BITMAP file. I am using some c source code to help me with what I need to do to read these files. My question is this:
How do you read x amount of data into a class and it sets the variables like with a struct? or does it automatically do this?
typedef struct /**** BMP file header structure ****/
{
unsigned short bfType; /* Magic number for file */
unsigned int bfSize; /* Size of file */
unsigned short bfReserved1; /* Reserved */
unsigned short bfReserved2; /* ... */
unsigned int bfOffBits; /* Offset to bitmap data */
} BITMAPFILEHEADER;
fread(&header, 1, sizeof(BITMAPFILEHEADER), filepointer);
This will set all the variables in the struct. I am looking to do this with classes... Is it possible? Also instead of using stdio.h I will be doing this <fstream>. Would that be the best way as well?
Any help would be greatly appreciated.
Thanks
Mike
How do you read x amount of data into a class and it sets the variables like with a struct? or does it automatically do this?
typedef struct /**** BMP file header structure ****/
{
unsigned short bfType; /* Magic number for file */
unsigned int bfSize; /* Size of file */
unsigned short bfReserved1; /* Reserved */
unsigned short bfReserved2; /* ... */
unsigned int bfOffBits; /* Offset to bitmap data */
} BITMAPFILEHEADER;
fread(&header, 1, sizeof(BITMAPFILEHEADER), filepointer);
This will set all the variables in the struct. I am looking to do this with classes... Is it possible? Also instead of using stdio.h I will be doing this <fstream>. Would that be the best way as well?
Any help would be greatly appreciated.
Thanks
Mike