Your file division is correct, but some details should be noted:
Your class Celular does not have none constructor. In the main code, you try to instill the class Celular by means of a builder that does not exist!
Change your main code to:
#include "Celular.h"
int main(int argc, char** argv)
{
Celular motorola; //Removido a chamada do construtor
motorola.ligar();
return 0;
}
In your file .h, the definition of the class Celular does not have ; (semicolon) at the end and also no sentinels to prevent redeclarations during the compilation stage.
Your file .h should be something like:
#ifndef CELULAR_H
#define CELULAR_H
class Celular
{
public:
void ligar();
};
#endif
And finally, your file .cpp, containing the implementation of the class Celular, makes two syntax errors, which fixed would make the file look like this:
#include <iostream>
#include "Celular.h"
using namespace std;
void Celular::ligar() //O tipo de retorno estava no lugar errado!
{
cout << "consegui" << endl; //Havia um erro de sintaxe aqui!
}
Huh!?
cout << "consegui" >>;!? I think this one>>shouldn’t be there. Or rather, usecout << "consegui" << endl;– Victor Stafusa
It’s me confused, it’s just as a test, I’m starting today
– diogo.alves
The error does not seem to have to do with separating files, and the question is without relevant information to help, colco that the names of all files, including those that do not appear there in the code. Could be just distraction and typo.
– Maniero