Menu

Why doesn't this header file compile?

2008-11-08
2012-09-26
  • Antonio Rueda

    Antonio Rueda - 2008-11-08

    Hi, I'm trying to compile the string.cpp and string.h files found in

    http://users.cs.fiu.edu/~weiss/dsaa_c++/code/

    I get a whole bunch of compiler error messages I don't understand. I've tried placing the files on the same folder and project and still fails. Why?

     
    • Antonio Rueda

      Antonio Rueda - 2008-11-08

      Thanks but the first one is a broken link and the other two aren't answering my question.

       
      • Wayne Keen

        Wayne Keen - 2008-11-09

        This link:

        https://sourceforge.net/forum/forum.php?thread_id=1035429&forum_id=48211

        Is not broken. The point of the Basic 3 is for you to provide the information that we need to fix your problem. They are not a magic solution to your problem.

        Wayne

         
    • Wayne Keen

      Wayne Keen - 2008-11-08

      Basic 3?

      Wayne

       
      • Antonio Rueda

        Antonio Rueda - 2008-11-08

        Huh?

        Well, I took out the vector.h and vector.cpp files from my project and managed to compile (yay), but I'm still failing to compile vector.cpp and vector.h on their own (which I need too).

        vector.cpp is failing to compile marking the #include "vector.h" statement. Why? Help! (please).

         
        • Wayne Keen

          Wayne Keen - 2008-11-08

          The basic 3 are covered in the thread titled: "Please Read Before Posting a Question" - the title is not an accident

          Wayne

           
    • cpns

      cpns - 2008-11-08

      > Why? Help! (please).

      The error messages that the compiler outputs are for diagnostic purposes. It is therefore obvious that we would want to see those in order to assist.

      Note that string.h is not an advisable file name since it is also the name of a standard library header (from teh C library subset of the C++ library). I note that the page you linked actually calls it mystring.h, presumably for that reason. Moreover its says "If you don't have a string type"; but you do! The page is not dated, but judging from the compiler versions it lists, I would guess it dates from the mid-1990's. There is no modern C++ compiler that does not include std::string, and std::vector. Basically you don't need either of these, and that is probably what was causing the problem.

      These files are presumably included to overcome shortcomings in these pre-ISO standard C++ compilers. You do not need them. Include <string> and <vector> and you will have the classes you need (in the std:: namespace).

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.