I will write the code of the header file and two .cpp
files I created under the same folder below. And I tried this under Visual Studio, gcc-gnu, and dev c++. I am getting the following error in the file employe.cpp
:
expected initializer before '.' token
employee.h
:
#ifndef employee
#define employee
#include <iostream>
using namespace std;
class employe{
public:
string name;
int id;
int salary;
void showInfos();
};
#endif
employe.cpp
:
#include "employee.h"
#include <iostream>
using namespace std;
void employe.showInfos(){
cout<<"Ad:"<<employe.name<<endl<<"Id:"<<employee.id<<endl<<"Salary:"<<employee.salary;
}
main.cpp
:
#include <iostream>
#include "employee.h"
#include <iostream>
int main(){
employe.id=21;
cout<<employe.id;
return 0;
}
main.cpp
errors:
expected unqualified-id before '.' token
expected primary-expression before '.' token
I meant to create my own header file and use it. But this happened.