473,320 Members | 1,867 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,320 software developers and data experts.

Container with pointers



Hi,
Can a container contains pointers to objects but hands out a references
to them?

somthing like the following:

std::map<long,Course_c*courses;
:
:
Course_c& course=courses[1000];
Thanks in advance.

Nov 3 '06 #1
1 1095

tomix wrote:
Can a container contains pointers to objects but hands out a references
to them?

somthing like the following:

std::map<long,Course_c*courses;
:
:
Course_c& course=courses[1000];
Not out of the box, no. But you could always put a wrapper around the
container to give it the functionality you want.

By the way, why do you want to do this? What's wrong with:

Course_c& course = *courses[1000];

?

Best regards,

Tom

Nov 3 '06 #2

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

Similar topics

5
by: edward.birch | last post by:
Can anyone see anything wrong with the following code? (CONTAINER can be list, vector, set, ...) template <class T> void Destroy(T * p) { delete p; } void...
14
by: PengYu.UT | last post by:
In the following program, I want an iterator contain pointer pointing to constant object not const pointer. If it is possible would you please let me know how to do it? #include...
4
by: Daniel Marques | last post by:
I would like to know how to get the address of a container of the STL without using iterators. I have a class with three STL lists and a index which points to an element of any ot the other lists,...
9
by: axel22 | last post by:
Hello, I have the following problem. I create a class called MyClass which includes another class calles MyContainer. Class MyContainer has a member which is a vector, instantiated as...
8
by: toton | last post by:
Hi, I am facing problem some times, and not finding a suitable answer to solve it. I have a vector (or some other container, sometimes) of some class, named CC like vector<CCv, NOT vector<CC*; ...
2
by: =?iso-8859-1?B?Tm9yZGz2dw==?= | last post by:
Hey there, C++ Coders. Does anyone know of a C++ (template) (vector) container that packs its elements based on their relative minimum and maximum value (offset and span) and (minimum) stride. ...
18
by: Goran | last post by:
Hi @ all! Again one small question due to my shakiness of what to use... What is better / smarter? private: vector<MyClass_t* itsVector; OR...
7
by: ademirzanetti | last post by:
Hi there !!! I would like to listen your opinions about inherit from a STL class like list. For example, do you think it is a good approach if I inherit from list to create something like...
8
by: puzzlecracker | last post by:
Guys, what is more preferable, given that I don't have access to boost or shared pointers: std::map<T*, std::set<T2** *_myMap; vs. std::map<T*, std::set<T2* *myMap; Notice that in the...
5
by: Olumide | last post by:
Hello - To begin with, I'm not the most experienced STL use out there but I'm slowly getting there. One bug(?) that's plagued me of recent is the way the OS (or is it STL?) appears to relocate a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.