Hi guys,
thank you so much for your help. I apologize if I have been posting too much or doing unintelligent code.
Thanks to Peter87 because now I dont have more compiling problems from the .h and .cpp files. Thanks to everyone explaining it, I understood it.
Now I have another problem with the program. I will write about it here because people already know the code.
I get this error:
multiple definition of `error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
It´s in a Header file called "myerror.h". Here is the code:
1 2 3 4 5 6 7 8 9 10 11 12
|
#ifndef MYERROR_H
#define MYERROR_H
#include <stdexcept>
#include <string>
using std::string;
//L01G4 S27/35
void error(const string& s ) { throw std::runtime_error{ s }; }
void error(const string& s1, string& s2 ) { error( s1 + s2 ); }
#endif // MYERROR_H
|
I know it´s because I have 2 functions that have the same name. But I have some doubts because:
1.- When commenting out the void error with 2 parameters (here the code):
1 2 3 4 5 6 7 8 9 10 11 12
|
#ifndef MYERROR_H
#define MYERROR_H
#include <stdexcept>
#include <string>
using std::string;
//L01G4 S27/35
void error(const string& s ) { throw std::runtime_error{ s }; }
//void error(const string& s1, string& s2 ) { error( s1 + s2 ); }
#endif // MYERROR_H
|
I receive almost the same announcement:
multiple definition of `error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
2.- Because the professor gave us that header file and somehow it worked in his computer without any problem...
Hope you help me!