Re: Question about arrays in objects
From: Leor Zolman (leor_at_bdsoft.com)
Date: 01/17/04
- Next message: Jerry Coffin: "Re: working with addresses"
- Previous message: Joec: "Re: Question about arrays in objects"
- In reply to: Joec: "Re: Question about arrays in objects"
- Next in thread: Jacques Labuschagne: "Re: Question about arrays in objects"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 17 Jan 2004 03:38:52 GMT
On Sat, 17 Jan 2004 03:11:45 GMT, Joec <joec@annuna.com> wrote:
>Wow it is pretty complex. Mainly I want a static array of objects as a
>data member. I am no expert at C++ but I am trying to expand the
>knowlege I have from several books. I am trying to apply what I have
>learned. The more I study the more I realize how much many books leave
>out and hard it is in choosing books.
One of the problems with talking about C++ is that certain terms,
"static" being arguably the worst offender, are way too "overloaded".
As a keyword, it has four different meanings in declarations based on
context. And then there's when it is used "conversationally" as an
adjective to describe storage duration. So what you're thinking when
you use the phrase "static array of objects" above may not be the same
as what pops into the mind of the person reading it. This is just a
C++ occupational hazard... ;-)
Case in point: let's take your phrase above, "static array of
objects". If you're literally meaning a data member declared with the
storage class specifier "static", then that means there's one copy of
that array shared among all the instances of the class you ever
create. Is that what you mean?
If you mean "fixed size", a la the "enum"-based example I gave you,
then there's no use of the word "static" that would generally apply to
it! For a class x defined like this:
class x {
enum { size = 100};
int array[size];
};
An instance at file (global) scope like this:
x x1;
would be said to have "static storage", but within a function like
this:
int foo()
{
x x2;
}
it would have "automatic" storage. And if you created an instance
like this:
x *xp = new x;
then it would have "dynamic" storage!
Just some food for thought...anyway, if you haven't added Scott
Meyers' Effective C++ to your book collection yet, run (don't walk) to
your bookstore or favorite online bookseller and do so!
-leor
>
>Thanks for the reply and the pointers.
Leor Zolman
BD Software
leor@bdsoft.com
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html
- Next message: Jerry Coffin: "Re: working with addresses"
- Previous message: Joec: "Re: Question about arrays in objects"
- In reply to: Joec: "Re: Question about arrays in objects"
- Next in thread: Jacques Labuschagne: "Re: Question about arrays in objects"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|