Thread: Need help with an assignment

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    2

    Need help with an assignment

    Description: Implement and test a C++ struct that represents an error record. An error record contains teh following information:

    Error code (ASCII text)
    Timestamp (TimeType)
    Priority (integer between 0 and 3 inclusive)
    Hi, first off my name is Adrian and I'm a college student who needs to take this level of CS for my major. Unfortunately it's been 2 years since I've even opened up any IDE and programmed.

    Here are the directions:

    The struct must implement the following operator overloads:

    1.) Overload functions for all relational operators ( ==, !=, <, <=, > , >=). The relational operators should evaluate each member of the error record in teh following order:

    Priority: One error record is logically less than another if the first has a smaller priority.
    Timestamp: given two error records with the same priority, one error record is logically less than another if the first has an earlier timestamp.
    Error Code: Given two error records with the same priority and timestamp, one error record is logically less than another if the first has an error code that is alphabetically less than the second.

    2.) Overload function for the insertion operator (<<).

    3.) The struct will be a simple C-style struct. It will not define any member functions.


    This is my header file ( ErrorType.h):
    http://rafb.net/paste/results/wpaqTR86.html

    This is my cpp (ErrorType.cpp):
    http://rafb.net/paste/results/VN48Nm14.html

    This is the professor's test file that tests my .cpp and .h
    http://rafb.net/paste/results/GhVnl388.html

    This is the .in file (error.in)
    http://www.themindofadrian.com/Error.in

    Here is a .zip of all the files for easy download and compile:
    http://www.themindofadrian.com/program1a.zip

    Ok, I hope I'm going the right way so far. I feel as though the directions weren't given very clearly. I and others asked in class and walked away thinking we knew what to do only to feel lost after getting past TimeType.

    A.) I don't know if my logic is right or I did the operator overloading right. I just copied from my notes and based it off examples.
    B.) What am I to do with Errortype? I need an example of what I should be doing inside those boolean functions.
    C.) Maybe a little bit easier explanation of what I'm suppose to do.

    Thank you,
    Adrian

    If there is ANYTHING else I can give so that it might be more helpful for you to help me, please ask.

    My
    aim = limitx3m
    yahoo = limitmaker

    It might say I'm away, but I'm not.

  2. #2
    Registered User
    Join Date
    Jul 2005
    Posts
    69
    I'd start by making this change in ErrorType.h. That way ErrorType will match up with the read order your instructor uses in the TestDriver file. Notice I commented out where you had originally placed errorCode.
    Code:
    struct ErrorType {
      std::string errorCode;
      unsigned    priority;
      TimeType    timestamp;
      //std::string errorCode;
    };
    Next I'd impliment
    Code:
    std::ostream& operator<<(std::ostream& out, const ErrorType& error)
    {
      out<<"";
      return(out);
    }
    so you can see when your making it this far in file Error.out.
    Last edited by Br5an; 09-08-2005 at 01:15 PM. Reason: Clarity

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    2
    Alright, now how do I start my error type?

  4. #4
    Registered User
    Join Date
    Jul 2005
    Posts
    69
    how do I start my error type?
    Ok, your question is not clear to me. If you have started making changes to a function, or operator overload, ect... please post the code section that you've worked on and the problem you are encountering.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Menu
    By Krush in forum C Programming
    Replies: 17
    Last Post: 09-01-2009, 02:34 AM
  2. Assignment Operator, Memory and Scope
    By SevenThunders in forum C++ Programming
    Replies: 47
    Last Post: 03-31-2008, 06:22 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Help with a pretty big C++ assignment
    By wakestudent988 in forum C++ Programming
    Replies: 1
    Last Post: 10-30-2006, 09:46 PM
  5. Replies: 1
    Last Post: 10-27-2006, 01:21 PM