473,404 Members | 2,170 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,404 software developers and data experts.

Overhead

When define member like "string" type for a class, we can either define it
as "char *" or "string." I don't know which one should be better. My
concern is that "string" has some "overhead" though its usage is so
convenient. Additionally 'string' member could be needed to pass into a
function which expect a variable of 'char *' Then the function call could
make the code looks like,

function(TheObject.PassMeTheStringMember().c_str() , 12, ...);

This is not that readable to me. I want to hear your opinion about this.
Another question is related to using STL. There are two classes, A and B:

class A
{
private:
list<Class B>InnerList;
....
};

class A contains a STL list. Could objects of type class A be put in
another std::list, OuterList (you see an iteration here)? Could it be put
in other type of container?

Thanks for your comments!
Jul 22 '05 #1
1 1692
In article <E6********************@bgtnsc05-news.ops.worldnet.att.net>, Garma wrote:
When define member like "string" type for a class, we can either define it
as "char *" or "string." I don't know which one should be better. My
You need to manage the memory somehow. It is usually better to avoid managing
multiple dynamic memory allocations within the one class (causes all sorts
of problems with exception safety, and makes code less clean). So you would
probably need to use *some* sort of class to manage the storage anyway.
concern is that "string" has some "overhead" though its usage is so
convenient.
What type of overhead ? Is this "overhead" causing any problems in your code ?
Additionally 'string' member could be needed to pass into a
function which expect a variable of 'char *' Then the function call could
make the code looks like,

function(TheObject.PassMeTheStringMember().c_str() , 12, ...);

This is not that readable to me. I want to hear your opinion about this.
In my opinion, it's readable (but it would be more so if you used shorter names
for your member functions!)
Another question is related to using STL. There are two classes, A and B:

class A
{
private:
list<Class B>InnerList;
...
};

class A contains a STL list. Could objects of type class A be put in
another std::list, OuterList (you see an iteration here)?
Yes
Could it be put in other type of container?


Yes

Cheers,
--
Donovan Rebbechi
http://pegasus.rutgers.edu/~elflord/
Jul 22 '05 #2

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

Similar topics

3
by: f.ruecker | last post by:
Hey Folks, I hope you'll be nice to me and let this post go through even know its mysql and not directly php. But of course my script is php. The problem is, that my Table (1,8 MIO entries/100...
7
by: Ireneusz SZCZESNIAK | last post by:
I want to sort a vector with the std::sort function. There are two functions: one with two arguments, the other with three arguments. I am using the one with three arguments. I noticed that...
9
by: Agoston Bejo | last post by:
Hello there, I would like to know what overheads there are to think of when using RTTI. I understand that enabling RTTI increases the sizes of the classes, but not the objects themselves. This...
3
by: Bob Rock | last post by:
Hello, this is something I've been asking myself for sometime ... and now I'd like to clarify this point. When should the try block start in a method??? What I mean is, does having all the code...
2
by: Showjumper | last post by:
By turning Option Strict on, is there extra overhead? For example w/o it on the following doesnt get flagged: validxhtml.Attributes.Add("height", 22) but with it on the 22 is underlined and the...
2
by: mark | last post by:
Hi, I am in the process of developing a small application that sits in the task bar and at a set interval polls an IIS web server for information. The process involves the client sending anything...
2
by: mmcgarry.work | last post by:
Hi, I would like to follow Stroustrup's advice of separating an object interface (abstract class) from an object implementation (concrete class), See Section 15.2.5 in Stroustrup 3rd Edition. ...
36
by: Peter Olcott | last post by:
So far the only way that I found to do this was by making a single global instance of the container class and providing access to the contained class, through this single global instance. Are...
5
ifedi
by: ifedi | last post by:
Hey guys, I've a mysql database with about 112 tables and views. All of the tables are INNODB. I manage this with phpmyadmin, and stuff have been pretty much fine over the last one and a half...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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
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.