10-07-2009, 12:55 PM
Hey.
So, I'm new to C++. I thought why not try and get into OOP. I don't think I quite understood how they work.
My program is supposed to work like an ATM machine. First off it should check user input for a name. And that's where I fail already. I just can't get it to work and I have no idea why.
The errors are i.e : ISO C++ forbids initialization of member `Name' ´; making `Name' static ; invalid in-class initialization of static data member of non-integral type `std:tring' ;
Thanks in advance
So, I'm new to C++. I thought why not try and get into OOP. I don't think I quite understood how they work.
My program is supposed to work like an ATM machine. First off it should check user input for a name. And that's where I fail already. I just can't get it to work and I have no idea why.
The errors are i.e : ISO C++ forbids initialization of member `Name' ´; making `Name' static ; invalid in-class initialization of static data member of non-integral type `std:tring' ;
Code:
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
class User
{
public:
string Name = 'Bob Kelso' ;
string Check(string x)
{
string com = Name;
if ( com == x)
{
cout << "You made it. Congratz" << endl;
}
}
};
int main()
{
string x;
cout << "Enter your name to withdraw money : " ;
cin >> x;
cin.ignore();
Check(x);
cin.get();
return 0;
}