ms visual 6.0

Sharky Forums


Results 1 to 8 of 8

Thread: ms visual 6.0

  1. #1
    Catfish f15e's Avatar
    Join Date
    Mar 2002
    Location
    I live in the south.
    Posts
    114

    ms visual 6.0

    I am using MS Visual C++ 6.0. Can anyone tell me why I am getting these errors within my header file(these are only a few of the errors):

    rror C2146: syntax error : missing ';' before identifier 'bkIsbn'
    c:\program files\microsoft visual studio\myprojects\book\book.h(13) : error C2501: 'string' : missing storage-class or type specifiers
    c:\program files\microsoft visual studio\myprojects\book\book.h(13) : error C2501: 'bkIsbn' : missing storage-class or type specifiers
    c:\program files\microsoft visual studio\myprojects\book\book.h(14) : error C2146: syntax error : missing ';' before identifier 'bkTitle'
    c:\program files\microsoft visual studio\myprojects\book\book.h(14) : error C2501: 'string' : missing storage-class or type specifiers
    c:\program files\microsoft visual studio\myprojects\book\book.h(14) : error C2501: 'bkTitle' : missing storage-class or type specifiers
    c:\program files\microsoft visual studio\myprojects\book\book.h(15) : error C2146: syntax error : missing ';' before identifier 'bkAuthor'
    c:\program files\microsoft visual studio\myprojects\book\book.h(15) : error C2501: 'string' : missing storage-class or type specifiers
    c:\program files\microsoft visual studio\myprojects\book\book.h(15) : error C2501: 'bkAuthor' : missing storage-class or type specifiers
    c:\program files\microsoft visual studio\myprojects\book\book.h(16) : error C2146: syntax error : missing ';' before identifier 'bkPublisher'

    Here is what I have in my header file:

    #ifndef _BOOK
    #define _BOOK

    class Book
    {
    private:
    string bkIsbn;
    string bkTitle;
    string bkAuthor;
    string bkPublisher;
    int bkPubYr;
    int bkNumInStock;
    int counter;
    double bkPrice;

    public:
    Book(string, string, string, string, int, double, int);
    ~Book();
    };

    #endif

  2. #2
    Mako Shark dighn's Avatar
    Join Date
    Nov 2000
    Location
    Vancouver, BC Canada
    Posts
    3,171
    yeah. to use string you need to include <string> then put "using namespace std;" after it (there are other ways but this shoudbe good enough)
    .

  3. #3
    Catfish f15e's Avatar
    Join Date
    Mar 2002
    Location
    I live in the south.
    Posts
    114
    I didn't think you needed that info within a .h file. The reason I say this is that I don't need it with the g++ compiler at school. All I needed was what you see in my post above. I will try and see what happens.
    THANKS!!

  4. #4
    Mako Shark dighn's Avatar
    Join Date
    Nov 2000
    Location
    Vancouver, BC Canada
    Posts
    3,171
    well that's probably because you included <string> somewhere before you included the header file... it depends on how you place the header files in order in the cpp file. i wouldn't rely on that so i'd put it in the h file anyway to be sure. it's a good practice anyway because you are using strings in your .h file.

    oh one other thing, you must have a "using namespace std" if you are not using g++. in my experience g++ for some reason ignore the namespace of the std library which is an incorrect behavior. at least i found this with g++ 2.9x, which is the mst common i believe. and make sure you are including <string>, not <string.h>
    Last edited by dighn; 09-18-2002 at 08:57 PM.
    .

  5. #5
    Catfish f15e's Avatar
    Join Date
    Mar 2002
    Location
    I live in the south.
    Posts
    114
    Thanks for the info. dighn!!

  6. #6
    Mako Shark dighn's Avatar
    Join Date
    Nov 2000
    Location
    Vancouver, BC Canada
    Posts
    3,171
    Originally posted by f15e
    Thanks for the info. dighn!!
    np
    .

  7. #7
    Hammerhead Shark Royal Oaks's Avatar
    Join Date
    May 2002
    Location
    Jessica Alba's throat
    Posts
    2,526
    Man ive noticed while doing some programming on Visual C++ 6.0 that i will get errors in places where there arent any. Granted i am using the introductory version that came with my book, but still. I will finish editing a program, and then i will go back to build and it will sometimes tell me i have errors when i dont. This even happens sometimes after i save the changes. It usually doesnt matter. I know for a fact that the compiler is making errors, because i will copy and paste what i have done and it will show up fine when i go to a new workspace. I dont know if anyhone has an similar problems, but i imagine this is only seen in the introductory version.
    Pyro's Updated 3dmark01/03 Guide
    "It takes time and study to undo the effects of evolutionary teachings"

    |:~T-Bred B~:| |:~nForce2~:| |:~GF4 Ti4600~:|

  8. #8
    Reef Shark biosx's Avatar
    Join Date
    Jun 2001
    Location
    Chicago, IL, USA
    Posts
    448
    The only time I had a problem with a compiler being lame was with Borland's free command line tools (C++ builder 5.5).

    It seriously wasn't generating the right object code and the values that I were printing (that were supposed to be various data) were showing up as zero's. I ftp'd the code (unaltered) to my school's solaris machine and compiled it there. Surprisingly, when I ran the program, it worked perfectly.

    I got rid of BCB and got mingw.
    ## root is the greed of all evil ##

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •