Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Please. Newbie at work. Failing.
#5
(10-07-2009, 01:22 PM)Code King Wrote: who has two thumbs and doesnt give a crap....bob kelso..have we met.

QFT Yeye



(10-07-2009, 01:59 PM)NinjaGeek Wrote: <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;
    
}

When I use your code, it stills gives me an error :S
Error : In member function ‘std:Confusedtring User::Check(std:Confusedtring)’:
AND
warning: control reaches end of non-void function

???
It works though, thanks. Kind of weird output when I enter the wrong name, but still Big Grin
Reply


Messages In This Thread
RE: Help Please. Newbie at work. Failing. - by TheDoctor - 10-08-2009, 08:19 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)