Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Please. Newbie at work. Failing.
#4
<sarcasam>wow Code King and Vorfin you are really helpful... </srcasam>

@Topic

You didn't initialize the class, take a look at the first two lines in main() and how the Check() is called, and the variable Name shouldn't be defined within the class
And also your function Check is set to return a string "string Check()" but it doesn't return a string wich may cause app to shutdown, instead of printing out the success message in Check() you should return it and cout when Check() is called

Code:
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;


class User
{
      public:
      string Name;
      
      
      string Check(string x)
      {
           string com = Name;
           if ( com == x)
           {
                return "You made it. Congratz";
           }
      }
      
};

int main()
{
  User *user = new User();
  user->Name = "Bob";
  string x;
  
  cout << "Enter your name to withdraw money : " ;
  cin >> x;
  cin.ignore();
  
  cout << user->Check(x) << endl;
  
  
  cin.get();
  return 0;
    
}
Reply


Messages In This Thread
RE: Help Please. Newbie at work. Failing. - by Gaijin - 10-07-2009, 01:59 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)