473,414 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

stl usage question

I have an object a

class object
{
private:
string streetname ;
vector listofhomes ;
}

i want to use STL template to build a program like

this class will have a

{ reed street,
list of houses in this street( names).
}

I want this to be collection. Like
{ streetname, list of houses)
(streetname, list of houses)...

How do i do it ?
Thanks in advance.

jk

Jul 19 '05 #1
3 1991
dm********@yahoo.com wrote:
I have an object a

class object
{
private:
string streetname ;
vector listofhomes ;
}
That's almost a class declaration. (You need a semicolon after
the closing brace.) It is not an object.
i want to use STL template to build a program like
Read through your writing before you publish it. People are
more likely to understand your question if it makes sense.
this class will have a

{ reed street,
list of houses in this street( names).
}
What?
I want this to be collection. Like
{ streetname, list of houses)
(streetname, list of houses)...
That's a very odd syntax. What does it mean?
How do i do it ?
Overload `operator >>' for objects of your class type. In your
`main ()' function, declare an object of type std::vector <object>.
Use std::copy, std::istream_iterator and std::back_inserter to read
the objects from a stream (either cin or an istream object you have
created) and insert them into the vector.
Thanks in advance.

jk


Regards,
Buster

Jul 19 '05 #2

<dm********@yahoo.com> wrote in message
news:rB***************@newssvr22.news.prodigy.com. ..
I have an object a

class object
{
private:
string streetname ;
vector listofhomes ;
vector requires a template argument,
e.g. vector<string>
}

i want to use STL template to build a program like

this class will have a

{ reed street,
list of houses in this street( names).
}

I want this to be collection. Like
{ streetname, list of houses)
(streetname, list of houses)...

How do i do it ?


vector<object> collection;

Alos I think you should have a more descriptive name
for your class than 'object', perhaps 'Street' or
'Houses', etc.

Which C++ book(s) are you reading?

-Mike

Jul 19 '05 #3

"Buster Copley" <bu****@none.com> wrote in message
news:bg**********@news7.svr.pol.co.uk...
dm********@yahoo.com wrote:
I have an object a

class object
{
private:
string streetname ;
vector listofhomes ;
}


That's almost a class declaration. (You need a semicolon after
the closing brace.) It is not an object.


Also needs a type parameter after vector, e.g.

class Street
{
private:
string streetname ;
vector<int> listofhomes ;
};
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ian Taite | last post by:
Hello, I'm exploring why one of my C# .NET apps has "high" memory usage, and whether I can reduce the memory usage. I have an app that wakes up and processes text files into a database...
3
by: Dan | last post by:
First, I'm sorry if this question has been asked too many times. I'm new to this news group. The question has to do with the use of popup windows in a web page. I have heard that popup windows...
12
by: DraguVaso | last post by:
Hi, How can I keep the memory usage and CPU usageas low as possible in a VB.NET application? any special techniques, any things to consider? Thanks a lot in advance, Pieter
0
by: Clemens Hintze | last post by:
Hello, I have a question concerning the usage of default constructed std::slice instances. Our company currently validate the GNU-G++ 3.4 compiler against the ISO/IEC 14882:2003 standard for...
7
by: George Gre | last post by:
Hi, I wrote a c# programme that listens to incoming TCP requests and services them. This programme is meant to be running as long as the server its installed on is running. So we assume for...
5
by: SDS | last post by:
I am writing an ASP.NET application (in C#) that, as part of a particular response, populates a MemoryStream object with binary data that is being collected from a Process object's StandardOutput. ...
3
by: M O J O | last post by:
Hi, A simple question... This is just an example ... Say I have a class (MyClass) that has only few variables (let's say 10 strings) but many-many-many subs and fuctions, so many subs and...
5
by: andrew | last post by:
Hello, I have a question about my usage of label as follows.... (sort of a combo html/css question) <p> <label>Field Name</label>Field Data </p> Now I know that a lable is generally...
11
by: Rares Vernica | last post by:
Hi, What is the right way/tool to find the peak memory usage of a C++ program? I tried Valgrind but is does not seem to be able to answer my question. Thanks a lot, Ray
26
by: rao | last post by:
On some of the compilers integer size is 2 and on some other it is 4 bytes. My doubt is who decides the size of the integer? is it plainly the compiler? Does OS or Processor also has any control...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.