Mar 1st, 2003, 04:37 PM
#1
Thread Starter
Member
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
Mar 1st, 2003, 05:05 PM
#2
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
Mar 1st, 2003, 05:15 PM
#3
Thread Starter
Member
Could that actually cause the problem??
Could that actually cause the problem??
Mar 1st, 2003, 05:20 PM
#4
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
Mar 1st, 2003, 05:20 PM
#5
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.
Mar 1st, 2003, 05:22 PM
#6
Thread Starter
Member
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.
Mar 1st, 2003, 05:25 PM
#7
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.
Mar 1st, 2003, 05:25 PM
#8
Thread Starter
Member
sorry
Please ignore my last post guys!! Just a brain fart...your advice works
Mar 1st, 2003, 05:28 PM
#9
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.
Mar 1st, 2003, 05:30 PM
#10
Thread Starter
Member
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
Mar 1st, 2003, 05:32 PM
#11
Thread Starter
Member
parenthesis??
Don't my function calls all have parenthesis already??
e.g. getName()
Mar 1st, 2003, 05:35 PM
#12
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
Mar 1st, 2003, 07:00 PM
#13
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
Forum Rules
Click Here to Expand Forum to Full Width