Home > Back-end >  [for] how to use the constructor for other functions in C initialization
[for] how to use the constructor for other functions in C initialization

Time:09-29

In c + + can be used in the function definition can be: to the initialization function,
There is a kind of writing is write constructor in: behind, for other functions initialization,
But an error when I was so with the editor, code roughly as follows:
 
BMPImage: : BMPImage () : m_width (0), m_height (0), m_depth (8), m_row_size (0),
M_data (nullptr), m_color_palette_size (0), m_color_palette (nullptr) {}

This is the constructor, class called BMPImage, followed is initialise variables,
Then I defined the other functions, the use of the constructor for the initialization:
 
BMPImage: : BMPImage (const char * bmp_file_path) : BMPImage () {}

This is another function, is to use: to invoke a constructor for the initialization, then editor to the following error:
C: \ Users \ User \ Desktop \ MKD \ extra \ BMPImage CPP 36 | | error: no matching function for the call to 'BMPImage: : BMPImage ()'
I in the constructor. H file also statement:
 
Explicit BMPImage ();

Ask anyone know what's going on, is I write wrong, or is that there is no this kind of writing?
  • Related