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

no ABC's in STL containers..


Recently tried to make a vector of a classe that contained a pure
virtual member. It didn't work. I've since found a little bit of
information including one possible solution:

http://pages.cpsc.ucalgary.ca/~kreme...x768/ref2.html

However the author mentions that the solution provided is not very
efficient. Was wondering if anyone here has solved this problem for
themselves in an efficient manner?

Cheers,
Sean
Jul 19 '05 #1
1 1529

"Sean" <se******@rogers.com> wrote in message
news:3M********************@news04.bloor.is.net.ca ble.rogers.com...

Recently tried to make a vector of a classe that contained a pure
virtual member. It didn't work. I've since found a little bit of
information including one possible solution:

http://pages.cpsc.ucalgary.ca/~kreme...x768/ref2.html

However the author mentions that the solution provided is not very
efficient. Was wondering if anyone here has solved this problem for
themselves in an efficient manner?

Cheers,
Sean


A vector of reference counted smart pointers is the usual solution. Seems
much more straightforward than the slightly wierd Ref2 class you quote. When
you use a vector for instance, much of the copying of element will happen
when the vector reallocates itself. In this case there is absolutely no need
to clone objects as Ref2 will. I think Ref2 is actually trying to solve a
different problem, that you have to use pointers to get poylmorphism in C++.
The Ref2 classs give value semantics to a pointer, at the cost of cloning
that pointer on each copy.

john
Jul 19 '05 #2

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

Similar topics

13
by: Dylan | last post by:
I'd like to compare two containers. They should be considered equivalent if both containers have the same number of elements with the same values, no matter what order the values are in. For...
7
by: Mike Smith | last post by:
Sorry about the multiple post, but I just realized my prior post was in a thread that dates back a couple of days, so people might not see it. Which is considered better for writing interfaces in...
14
by: phil_gg04 | last post by:
Dear C++ Experts, Over the last couple of months I have been writing my first program using shared memory. It has been something of an "in-at-the-deep-end" experience, to say the least. At...
18
by: Matthias Kaeppler | last post by:
Hi, in my program, I have to sort containers of objects which can be 2000 items big in some cases. Since STL containers are based around copying and since I need to sort these containers quite...
8
by: Gregory | last post by:
I have a question about using STL containers in C++ class public interface. Lets say that I want to return some container from class method or accept class method parameter as some container. For...
2
by: bob | last post by:
Hi, Given: 1) Custom containers that have nothing to do with vector, deque, list, map etc, 2) a custom version of new and delete defined for these containers, customNew and customDelete,...
1
by: Jean-Marc Blaise | last post by:
IBM recommends to place each ts container on a different physical disk. What about the impacts if all containers (DMS) are in the same FS (supported by multiple disks) ? Does DB2 preallocate...
15
by: Nindi73 | last post by:
HI If I define the class DoubleMap such that struct DoubleMap : public std::map<std::string, double>{}; Is there any overhead in calling std::map member functions ? Moreover are STL...
11
by: jimxoch | last post by:
Hi list, Most STL containers are storing their data on the heap. (although some std::string implementations are notable exceptions) Of course, using the heap as storage increases flexibility and...
34
by: Umesh | last post by:
I want to extract a string abc*xyz from a text file. * indicates arbitrary no. of characters. I'm only able to do it when the string has definite no. of characters or the string length is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.