class and giving in function or class problems ???

This is a discussion on class and giving in function or class problems ??? within the C++ Programming forums, part of the General Programming Boards category; I know how to get valuables from functions and classes but I don't know how to put in to them ...

  1. #1
    beginner for now
    Join Date
    Oct 2009
    Posts
    35

    Unhappy class and giving in function or class problems ???

    I know how to get valuables from functions and classes

    but I don't know how to put in to them

    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    
    class login
    {
          private:
                  string name;
          public:
                 string return_name ()
                 {
                        cout << "before you enter to our games please tell us your name\n\n";
                        getline (cin, name);
                        cout << "thank you for sharring information " << name << endl;
                        return name;
                 }
    };
    
    
    
    
    class namex
    {
        cout << "nameq\n";
    }
    
    
    int namey ()
    {
        cout << "nameq\n";
        return 0;
    }
    
    
    int main()
    {
        login log;
        string nameq;
        nameq = log.return_name ();
        cout << "hello: "<< nameq <<"\n\n\n";
    
        namex ();// don't know how to put here that name I input in login
        namey ();// don't know how to put here that name I input in login
    
        return 0;
    }

    please fill up what is missing
    or repair

    I'll learn much from this

  2. #2
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    These are called properties in which u just want to get and set operation on some data

    Code:
    class login
    {
          private:
                  string name;
          public:
                 string return_name ()
                 {
                        cout << "before you enter to our games please tell us your name\n\n";
                        getline (cin, name);
                        cout << "thank you for sharring information " << name << endl;
                        return name;
                 }
                void set_name(const string __name) {
                   name = __name; 
                   // or memcpy(__name, name, strlen(__name)); if it is char*
                }
    }

  3. #3
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Quote Originally Posted by military genius View Post
    please fill up what is missing
    or repair

    I'll learn much from this
    how would you learn anything if we "filled up whats missing" or "repaired" your code for you?

    anyways, i dont understand your post. are you talking about passing arguments / parameters to functions? if so then search here or anywhere else for those keywords and youll find your answer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. printf("04x",short) - negitive hex giving me problems
    By KairosDrasis in forum C Programming
    Replies: 3
    Last Post: 12-09-2008, 10:51 AM
  2. My most amazing error yet! [complicated]
    By therabidwombat in forum C++ Programming
    Replies: 33
    Last Post: 11-02-2006, 01:54 PM
  3. templates giving me problems
    By jlf029 in forum C++ Programming
    Replies: 4
    Last Post: 12-21-2005, 04:34 PM
  4. Simple thread object model (my first post)
    By Codeplug in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2004, 10:34 PM
  5. Is it possible to have callback function as a class member?
    By Aidman in forum Windows Programming
    Replies: 11
    Last Post: 08-01-2003, 11:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21