Main function error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Soko San
    New Member
    • Dec 2011
    • 5

    Main function error

    Sorry for bothering :( but another error happened when I tried to write the main function.
    It says : error C2228: left of '.getLoadFactor ' must have class/struct/union type

    Not calling loadfactor is the only problem but when I try to call any one of them (insert,remove. ..)
    Anyone know what this mean? And especially HOW to fix it??

    Greetz
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    The error is here:

    Code:
    HASH STUDENT();
    This is a call to the HASH default constructor. The compiler creates a temporary HASH object for this statement, calls the HASH constructor, and then deletes the temporary object at the end of the statement.

    Just do this:

    Code:
    HASH STUDENT;
    This tells the compiler to create a local variable of type HASH named STUDENT and then to call the default HASH constructor to initialize the variable.

    Comment

    • Soko San
      New Member
      • Dec 2011
      • 5

      #3
      Ok I did what u said the error has gone but a run time error has happened why???? is there anything wrong with my array??? what should I do??

      Can u show how to write a good main function to test this implementation? ?

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Probably you are going outside the array bounds.

        There are no checks in your code to make sure you are inside your array.

        My first suggestion is to use std::string instead of arrays. std::string has all the protective code needed to stay inside the array used by std::string.

        Otherwise, you step through the code using your debugger to see where the crash occurs.

        As to testing, that's a big subject. I would suggest that you test using data that you know is smaller than your arrays. When you get it working this way, then you can provide data designed too provoke a crash.

        Comment

        • Soko San
          New Member
          • Dec 2011
          • 5

          #5
          I think I understand I will try what u said thank u very much for helping me
          u were very helpful :)
          thanks again

          Comment

          Working...