main.cpp:
#include "Login.h"
int main () {
Login();
}
Login.h:
#ifndef LOGIN_H
#define LOGIN_H
#include <string>
#include <iostream>
using namespace std;
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 ()
{
Login lo;
lo.setInput("hello");
cout << lo.getInput();
};
I'm just learning to program and I'm trying to make a simple program to display input, but to use a class and object to do it, so I can learn how and ultimately make a program that starts with a login (hence all the "login" names).
When I run this it just crashes, and I have no idea why, or how i would search for a solution to this online, because I don't know even remotely what the problem is.
My question is two-fold:
1. Why is this just crashing?
2. How could I set the parameter in lo.setInput to a user input? (cin)