Help please

This is a discussion on Help please within the C++ Programming forums, part of the General Programming Boards category; Here is the code: Code: #include<iostream.h> #include<conio.h> #include<string.h> class Order { Order yearEndTotal(Order summary, Order oneOrder); private: char customerName[20]; int ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    3

    Help please

    Here is the code:

    Code:
    #include<iostream.h>
    #include<conio.h>
    #include<string.h>
    class Order
    {
      Order yearEndTotal(Order summary, Order oneOrder);
      private:
        char customerName[20];
        int orderQuantity;
      public:
        Order();
        setValues();
        displayValues();
    };
    Order::Order()
    {
       strcpy(customerName,name);
       orderQuantity=0;
    };
    void setValues()
    {
      cout<<"Enter customer name ";
      cin>>name;
      cout<<"Enter quantity ordered: ";
      cin>>orderQuantity;
    };
    void Order::displayValues()
     {
       cout<<customerName<<" ordered "<<orderQuantity<<"items."<<endl;
     };
    Order yearEndTotal(Order summary, Order oneOrder)
     {
        summary.orderQuantity = oneOrder.orderQuantity;
        return(summary);
     };
      void main()
     {
        const int ORDERS = 10;
        Order anOrder[ORDERS];
        Order summary;
        int x;
        for(x=0; x<ORDERS; ++x);
          anOrder[x].setValues();
       for(x = 0; x< ORDERS; ++x)
         {
           summary = yearEndTotal(summary,anOrder[x]);
         };
        summary.displayValues();
        getch();
      };

    All I have to do is debug and I am not able to fix the seven erros that I am getting. Can anyone help?

  2. #2
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    NEVER use void main, its WRONG.

    That and you havent declared most of your variables, just used them. Start with the cprog tutorials.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    3
    I didn't write the program. It was given to me and what I have to do is compile, build and fix any errors. If I can change to int main() I don't know. This is how it was given to me.

  4. #4
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    so its homework, do some reading and stay awake in class.

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    3
    Actually it's not my homework. I have a sister that was in a bad accident and in the hospital, with only four weeks left in class and not wanting to drop I was trying to help her. Someone recommended this site to me, said the people were great and a huge help....I have yet to find that.

  6. #6
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    >>said the people were great and a huge help

    We are, but not when someone is trying to weasel out of homework. You need to read the errors, if it says undeclared then you need to declare it before you use it. Example, you have

    cin >> name;

    but you never declare the variable, ie

    string name;

    Show some effort, and post updated code if you get stuck.

  7. #7
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    class member func prototypes dont match functions.Specify correct return values. void is never implicit.fix that and if you get more errors post them. hard to fix errors if you dont give us more of a clue. your compiler is your biggest friend. learn to use it.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

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