Hi all,
I'm making a library with functions that validate a user's input and returns it if it's valid. I'm encountering the same debugging errors, "Redundant redefinition of (function)" in my implementation file. My header file seems to be fine
.....lines of code before this work. The bolded ones are where the errors are.
double input_prot (string prompt, string err, double upper){double input;
cout<<prompt;
cin>>input;
if (cin.fail()){ //if it isn't even a double
cout<<"invalid input'/n'";
cin.clear() ;
cin.ignore();
}
elseif (input>upper){ //double but out of bounds
cout<<err<<endl ;
cin.clear();
cin.ignore();
}
else {
return input;
}
return input;
}//closes function
long input_prot (string prompt, string err, long upper){long input;
cout<<prompt;
cin>>input;
if (cin.fail()){ //if it isn't even a long
cout<<"invalid input'/n'";
cin.clear() ;
cin.ignore();
}
elseif (input>upper){ //long but out of bounds
cout<<err<<endl ;
cin.clear();
cin.ignore();
}
else {
return input;
}
return input;
}//closes function
double input_prot (string prompt, string err, double lower){double input;
cout<<prompt;
cin>>input;
if (cin.fail()){ //if it isn't even a double
cout<<"invalid input'/n'";
cin.clear() ;
cin.ignore();
}
elseif (lower >input){ //double but out of bounds
cout<<err<<endl ;
cin.clear();
cin.ignore();
}
else {
return input;
}
return input;
}//closes function
long input_prot (string prompt, string err, long lower){long input;
cout<<prompt;
cin>>input;
if (cin.fail()){ //if it isn't even a long
cout<<"invalid input'/n'";
cin.clear() ;
cin.ignore();
}
elseif (lower >input){ //long but out of bounds
cout<<err<<endl ;
cin.clear();
cin.ignore();
}
else {
return input;
}
return input;
}//closes function
Thank you!
To fix it, I just switched around the parameters so that the same types wouldn't line up. After a little more debugging, the program runs perfectly now.