Thread: type class question 2

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    46

    type class question 2

    If I have the following code which is a gas feed program:
    Code:
    class throttle
    {
    public:
           void shut_off();
           double flow();
    private:
           int position;
    };

    How would I declare an instant or throttle called test? Would it be throttle.test?
    Also I would want to activate the member function that shtus off test's flow, and then print out the current flow from test.

    would it be?:
    Code:
    throttle.test
    void shut_off(test)
    cout<< flow(test)    //<---no idea about print out???

    Your help would really be appreciated

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    How would I declare an instant or throttle called test? Would it be throttle.test?
    Code:
    throttle test;
    Also I would want to activate the member function that shtus off test's flow, and then print out the current flow from test.
    Code:
    throttle test;
    test.shut_off;
    cout << test.flow;
    No offense, but the questions you posted suggest an incomplete understanding of functions, and concepts of a similar level. Before continuing with the object oriented features of C++, I would suggest that you take some more time to get more comfortable with defining and using your own functions.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    46
    Quote Originally Posted by sean_mackrory
    Code:
    throttle test;

    Code:
    throttle test;
    test.shut_off;
    cout << test.flow;
    No offense, but the questions you posted suggest an incomplete understanding of functions, and concepts of a similar level. Before continuing with the object oriented features of C++, I would suggest that you take some more time to get more comfortable with defining and using your own functions.
    no offense taken sean, thanks for your help, with this board and my readings I plan on furthering my knowledge, thanks for the suggestions

  4. #4
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    Quote Originally Posted by sean_mackrory
    Code:
    throttle test;
    test.shut_off;
    cout << test.flow;
    should be
    Code:
    throttle test;
    test.shut_off();
    cout << test.flow();

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you check what is wrong with this code
    By Ron in forum C++ Programming
    Replies: 4
    Last Post: 08-01-2008, 10:59 PM
  2. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  3. Quick question about class template
    By merixa in forum C++ Programming
    Replies: 5
    Last Post: 12-06-2005, 11:43 PM
  4. Replies: 3
    Last Post: 10-31-2005, 12:05 PM
  5. "error: incomplete type is not allowed"
    By Fahrenheit in forum C++ Programming
    Replies: 9
    Last Post: 05-10-2005, 09:52 PM