main.cpp
#include "Login.h"
int main () {
Loginf();
}
Login.h
#ifndef LOGIN_H
#define LOGIN_H
#include <string>
#include <iostream>
using namespace std;
void Loginf ();
class Login
{
public:
Login ();
string getInput () {
return input;
}
void setInput (string x) {
x=input;
}
private:
string input;
};
#endif
Login.cpp
#include "Login.h"
Login::Login () {};
void Loginf () {
Login lo;
lo.setInput("hello");
cout << lo.getInput();
};
A simple program that i started with to display an input to the screen. However, when i build it, all i get is this:
mingw32-g++.exe -o "bin\Debug\first project.exe" include\Login.h.gch obj\Debug\main.o obj\Debug\src\Login.o
include\Login.h.gch: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
I have no idea why its giving me this. The reason for this program is to figure out how to use header files with functions prototypes and a class with an object so that i can create a program with a simple login. So, I need to keep the function and the class, I don't want to have to simply define the function in main or something like that.
So my question, to sum this up, is simply: why won't this code run, and what can I do to fix it without changing the format (main.cpp calls the function, login.h prototypes it and creates the class, login.cpp defines the function).