|
-
March 2nd, 2010, 05:38 AM
#1
Vectors
Hi, I am quite new to c++ and finding it hard to get used to the added functions - I used to use Java..
Anyway I have to create a class house which has a number of member variables that represent a vehicle which I assume is like this
class house
{
string type;
string colour;
string number;
}
And then make a suitable constructor and method toString to return output
string house::toString()
{
string("House is ( " + type + ", " +
colour + ", " +
number +")");
}
but when I do this it says string house::toString() 'expected primary-expression'... I'm so confused!
After I've done this I need to make house into a vector so I can have additional houses - apparently I need to make a class like this
class HouseGroup
{
private:
vector<string> House;
public:
Void addHouse(House v);
string toString();
}
string toString is meant to create a string representation of the entire collection.. ?
If anyone could explain to me how a vector works and how I would go about it I'd be very grateful! Thanks
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
|