Constructors problems

Hello there !

I am trying to make a constructor which initializes one of my objetcs with 4 parameters. The problem is when I try to compile, I have errors.


In my main, I have :
 
  ppm_file file("my_ppm_file.ppm", 100, 100, 255);


In my header, I have :
 
   ppm_file(char name, unsigned int width, unsigned int height, unsigned int max_level);



The error is :

/Users/alexandre/image_du_ciel/main.cpp:10: erreur : no matching constructor for initialization of 'ppm_file'
ppm_file file("my_ppm_file.ppm", 100, 100, 255);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I don't understant my mistake.

By advance, thank you.
did you make a body for the ctor?
and is it public?
Last edited on
"my_ppm_file.ppm" <-- this is a string literal, which can either be referenced as a const char*, or turned into an std::string.

1
2
3
4
5
#include <string>

// ...

ppm_file(const std::string& name,unsigned int width, unsigned int height, unsigned int max_level);
Last edited on
Yes the constructor has a body and is public.

Ganado, I tried your solution and it seams to be okay. Thanks' !
Topic archived. No new replies allowed.