Results 1 to 13 of 13

Thread: Class Definition and string data members

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    47

    Question Class Definition and string data members

    Hello, all!

    I'm having some problems writing a class definition while using string data members.

    I'm using string type members of the string class. That's okay right? Or should I be using c-strings (char arrays?).

    In any case, I'm receiving a number of error messages:

    - missing storage class...
    - missing ";" before identifier varname (i.e. string varname)...it's telling me to put a ";" after string...yeah right.

    Attached is my code. It's probably just something stupid. Can you see the error or errors anywhere?

    Thanks!!
    Attached Files Attached Files

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    You shouldn't be using <iostream.h> or <string.h>, as they are deprecated (or however you spell it)

    Change the top of your code to look like this :
    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    47

    Could that actually cause the problem??

    Could that actually cause the problem??

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Well, I got the same errors with your original source, then changed it, and it worked. So I'd have to say yes.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    crptcblade: spelling is correct

    cplususer: yes, it could. If not I don't know what the problem is.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    47

    Question

    I've been using the so-called depricated <iostream.h> and <string.h> for a while now and they've never caused a problem.

    Unfortunately, this does not seem to be the problem with my program. It's something else.

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Ok, so it's not the problem. But still the deprecated headers ARE deprecated so you shouldn't use them. There are some newer compilers that don't support them anymore.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    47

    sorry

    Please ignore my last post guys!! Just a brain fart...your advice works

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Oh, and one thing:
    Code:
    cout << "v1 vehicleID value: " << v1.getVehicleID() << "v1 vehicleColour value: " << v1.getVehicleColour() << endl;
    cout << "v2 vehicleID value: " << v2.getVehicleID() << "v2 vehicleColour value: " << v2.getVehicleColour()  << endl;
    cout << "p1 ownerID value: " << p1.getOwnerID()  << "p1 name value: " << p1.getName() << endl;
    cout << "p2 ownerID value: " << p2.getOwnerID()  << "p2 name value: " << p2.getName() << endl;
    In C++, unlike VB, functions need parentheses for calling, even when there are no arguments. Your code is missing all parentheses.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    47

    Talking cornedBee

    Just wondering how you format those little code snippets?

    Use some sort of HTML tags??

    Thanks for you help!!! You've been very helpful

  11. #11

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    47

    parenthesis??

    Don't my function calls all have parenthesis already??

    e.g. getName()

  12. #12
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    Re: cornedBee

    Originally posted by cpluspluser
    Just wondering how you format those little code snippets?

    Use some sort of HTML tags??

    Thanks for you help!!! You've been very helpful
    [code][/code]
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  13. #13
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    The file you uploaded didn't have them in the 4 cout lines.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width