Problem compiling C++ class -
I'm running a C ++ program that is another Uses a square from CPP file. There is only one constructor in the classroom. This works when I check it separately, it compiles the main program, but when I run it, I have a bug in the constructor. Can anyone think of any situation? Thank you.
I think I just run the code in the terminal, and it's okay. But when I try to create a project in Eclipse, it shows that the following code has many definition errors:
class model {public: int texture []; Float corner [] [3]; Float triangle [] [13]; Public: Model (const char *); // constructor}; Model :: model (const char * filename) { The error message is: Many definitions of `model :: model (char const *) '
Any ideas?
H (header) and a CPP (implementation) file should be split into and put:
model :: model (const char * filename) { the latter To rewrite your class in or to, so that the constructor's definition (and any other member works) is inside the class in the title file:
class model {... model (const char * ) {// constructor body here}};
Comments
Post a Comment