1
I am creating a system of records and login as a form of practice, but I keep finding this error and although searched a little, I can not find the solution.
#include "registration.h"
//Outras porções do código
if (password == "")
{
cout << "You aren't registered! \n\n";
registration();
}
//Registration.h
//Inicialização normal do header, iostream e namespace.
void registration()
{
cout << "Choose a password: ";
cin >> password;
cout << "Successfully registered! \n\n";
cout << "Now you must login. \n\n";
login();
prompt();
}
Error:
C: Program Files (x86) Codeblocks Projects authsystem login. h|22|error: 'Registration' was not declared in this Scope|
What I tried:
Declare that the function is void, but not manifest in the application.
Declare function on itself .h
, but does not work due to the order that the application is.
Another case where a virtually identical function is called, but it works:
if (attempt == password)
{
cout << "Logged in successfully. \n \n";
prompt();
}
Do you understand Spanish? If so, take a look at this link: https://es.stackoverflow.com/a/54921
– Luiz Augusto
Not much, and translating the page doesn’t improve things. I updated the code on top.
– jamescodec
Are you including code in a . h? This is usually not what you want.
– Jefferson Quesado
That @Jeffersonquesado , so that everything did not stay in main.cpp, I decided to separate the functions in headers. Each header presents only the function, without any class, which does not seem to have given me problems in the past.
– jamescodec
Perhaps I can help, perhaps I am even a duplicate of the question I answer here: https://answall.com/a/213804/64969
– Jefferson Quesado
@jamescodec, one should avoid codes in header files (with the exception of template functions). There are exceptions beyond template functions, but your code is no exception. The correct one would be to have only the statement in the header and the code in another . cpp, doing the partial compilation of the source files. And, no, I don’t know how to do that in code::
– Jefferson Quesado