I need help in understanding an assignment

I am working on an assignment and my instructor says that I do not have a main method.  I do not understand what is meant by this.  I would appreciate any feedback. I am sure that is a basic program and it is as follows:

"you are the owner of a hardware store and need to keep an inventory that can tell you what different tools you have, how many of each you have on hand, and the cost of each one.  Write a program that initializes the random-access file "hardware.dat" to one hundred empty records, lets you input the data concerning each tool that you no longer have and lets you update any information in the file."  Then information is given regarding the record numbers, tool name, quantity and cost.  

Here is the code that I have in my .cpp file.  

//
#ifndef HardwareData_h
#define HardwareData_h

#include <iostream>

using std::string;

class HardwareData {

public:

      HardwareData (int = 0, string = "", string = "", double = 0.0);

      void setRecordNumber( int );
      int getRecordNumber() const;

      void setToolName(string);
      string getToolName() const;

      void setQuantity(string);
      string getQuantity() const;

      void setCost (double );
      double getCost() const;

private:
      int RecordNumber;
      char ToolName [20];
      char Quantity [4];
      double Cost;

};

#endif


Thank you.


klrqueen13Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

grg99Commented:
You have to actually write the code that implements all those nice functions.

for example:

void SetRecordNumber( int r ) {   RecordNumber = r; }
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
klrqueen13Author Commented:
Do you mean in say a hardware.h file?  I have been working on this for hours and hours..and am still lost.
0
brettmjohnsonCommented:
> I am working on an assignment and my instructor says that I do not have a main method.  
> I do not understand what is meant by this.

Computer programs must have an initial entry point where the program begins execution.
By convention, the c (and c++) runtime library defines that starting point as a function called
main().   By including a function called main() in your program, you are instructing the C runtime
that the program starts 'here'.

0
Sys_ProgCommented:
Go thru this link for starting to write your program. It provides an explanation of the main() method etc.

http://computer.howstuffworks.com/c.htm


Regarding your cpp file implementation,

In C++, U should declare the class in a .h (header) file and the implementation (define the class) in a .cpp (iplementation) file.
These links would help

http://www.gamedev.net/reference/articles/article1127.asp
http://juicystudio.com/tutorial/cpp/files.asp
http://www.cprogramming.com/tutorial/lesson12.html


Amit
0
itsmeandnobodyelseCommented:
>> Here is the code that I have in my .cpp file

- Move all your code to a file called 'hardwaredata.h'.

- Change

         #include <iostream>

  to

         #include <string>

   in hardwaredata.h


- Add the following include statements to the (now empty) cpp file

    #include "hardwaredata.h"

    #include <iostream>
    #include <string>

    using namespace std;

- Add an implementation for all your class member functions, e. g.

     HardwareData::HardwareData (int RecNum,
                                                  string strToolName,
                                                  string strQuantity ,
                                                   double dCost)
          :  RecordNumber(RecNum)
          , Cost(dCost)
     {
           if (strToolName.length() < sizeof(ToolName))
                strcpy(ToolName, strToolName.cstr());
           else
           {
                  cout << "Tool-Name " << strToolName << ", string is too long " << endl;
           }
               
           if (strQuantity.length() < sizeof(Quantity))
                strcpy(Quantity, strQuantity.cstr());
           else
           {
                  cout << "Quantity " << strQuantity << ", string is too long " << endl;
           }
                         
     }

     void HardwareData::setRecordNumber( int RecNum )
     {
            ...
     }

     int HardwareData::getRecordNumber() const
     {
           ....
     }

     void HardwareData::setToolName(string strToolName)
     {
           ....
     }

     string HardwareData::getToolName() const
     {
          .....
     }

     void HardwareData::setQuantity(string strQuantity)
     {
          ....
     }

     string HardwareData::getQuantity() const
     {
          ....
     }

     void HardwareData::setCost (double dCost)
     {
          ....
     }
 
     double HardwareData::getCost() const
     {
          ....
     }


- Finally, you need a main() function where you can test your class.

  Add the function below all other implementations.

   int main(int nArgs, char* pszArgs[])
   {
         HardwareData hd1;
         hd1.setRecordNumber(1);
         hd1.setToolName("Case");
         ....

         HardwareData pHd2 = new HardwareData(2, "Keyboard", "12", 12.99);  
         double cost = pHd2->getCost();
         ....

         delete pHd2;

         return 0;  
   }


TODO:  replace ....  by  implementation code.

Regards, Alex





0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.