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

Class and Container

Hi,

In real world, when to use class, container, class & container? It
seems to me that container is more useful to number chain, class is for
implementing complex porjects? Right? Please give your insights.

Thanks in advance,
Michael

Aug 5 '06 #1
6 1554
* Michael:
>
In real world, when to use class, container, class & container? It
seems to me that container is more useful to number chain, class is for
implementing complex porjects? Right? Please give your insights.
In C++ a container is a class.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Aug 5 '06 #2

Alf P. Steinbach wrote:
* Michael:

In real world, when to use class, container, class & container? It
seems to me that container is more useful to number chain, class is for
implementing complex porjects? Right? Please give your insights.

In C++ a container is a class.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Sorry for not clarifying my questions. I would like to know when shall
I create my own class or use STL container?

Thanks,

Aug 5 '06 #3
* Michael:
[quoting signature]]
Please don't quote signatures -- corrected.
* Michael:
Alf P. Steinbach wrote:
>* Michael:
>>In real world, when to use class, container, class & container? It
seems to me that container is more useful to number chain, class is for
implementing complex porjects? Right? Please give your insights.
In C++ a container is a class.

Sorry for not clarifying my questions. I would like to know when shall
I create my own class or use STL container?
Should you choose the blonde or the brunette, that's the question.
Well, if you absolutely feel you have to choose one or the other, try
both, and choose the one that pleases you the most, or, be more
pragmatic and choose both. ;-) Seriously.

Generally the purpose of a class is to maintain a class invariant, a set
of relationships between the instance data members. The class invariant
is established by the class' constructor and maintained by every public
member function.

If a standard container doesn't give you the class invariant you want,
then a custom class is called for.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Aug 5 '06 #4
"Michael" writes:
In real world, when to use class, container, class & container? It
seems to me that container is more useful to number chain, class is for
implementing complex porjects? Right? Please give your insights.
You write your own class when you can't find an STL container that does what
you want. Hideously complex projects can be done with just the STL and C++
or even just C++ or even just C so complexity is of no use as a metric. .
Aug 5 '06 #5
"Michael" <mi*******@gmail.comwrote:
In real world, when to use class, container, class & container? It
seems to me that container is more useful to number chain, class is for
implementing complex porjects? Right? Please give your insights.
Maybe if you gave some examples where you think either a class or
container could be used, and we can tell you what we would use in that
situation.
Aug 5 '06 #6
On 5 Aug 2006 10:34:34 -0700 in comp.lang.c++, "Michael"
<mi*******@gmail.comwrote,
>Sorry for not clarifying my questions. I would like to know when shall
I create my own class or use STL container?
I prefer to use the STL container classes whenever they fulfill the
requirements of the program.

Aug 5 '06 #7

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

Similar topics

20
by: syd | last post by:
In my project, I've got dozens of similar classes with hundreds of description variables in each. In my illustrative example below, I have a Library class that contains a list of Nation classes. ...
8
by: CoolPint | last post by:
I read in books that nested class cannot access private members of nesting class and vice versa unless they are made friends. Somehow, my compiler is letting my nested class member functions access...
3
by: Vincent Cantin | last post by:
I have a class defined by a template which needs to "say" its type to the user via string. As an example, here is the class that I want to fix : template<class T> class Container : public...
4
by: WittyGuy | last post by:
Hi all, Though I know the concepts of both abstract class & virtual function (like derived class pointer pointing to base class...then calling the function with the pointer...), what is the real...
2
by: Gastin | last post by:
I am consuming a web serivce from Amazon.Com. I have the following class which was autogenerated by VS.NET when I created a Web Reference to...
3
by: Trammel | last post by:
Hi, I recently upgraded to VB.net from VB6.. and woah... I feel lost :¬O One of my reasons for upgrading is I was told that VB.net can do class inheritance and subclassing easier. ...
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...
12
by: jimmij | last post by:
Hi, Please look at the code bellow /*******************/ class ctab { private: static const unsigned n=48;
11
by: food4uk | last post by:
Dear all : I am not good at programming, please give a hand. My data structure is very similar as an array. I actually can use the std::vector as container to organize my data objects. However,...
2
by: Daniel Lipovetsky | last post by:
I would like for an object to "report" to a container object when a new instance is created or deleted. I could have a container object that is called when a new instance is created, as below. ...
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.