I take it I cannot form a container of an array type? For example,
stack<string[3]> parentStack;
TIA,
sjfromm 7 1625
"Stephen J. Fromm" <st***********@verizon.net> wrote... I take it I cannot form a container of an array type? For example, stack<string[3]> parentStack;
Yes.
On 29 Jul 2003 10:18:57 -0700, st***********@verizon.net (Stephen J.
Fromm) wrote: I take it I cannot form a container of an array type? For example, stack<string[3]> parentStack;
TIA,
sjfromm
You can have containers of arrays, but the declaration youv'e posted
above is faulty. Youv'e declared a stack where each element is 3
strings. This is fine in principle, but probaly what you should do is
declare a struct that defines the stack elements, then declare the
stack as a stack of those things, like this:
struct STRINGS
{
string m_Strings[3];
}; // STRINGS
int main()
{
std::stack<STRINGS> stk;
return 0;
}
</dib>
John Dibling
Witty banter omitted for your protection
John Dibling wrote: On 29 Jul 2003 10:18:57 -0700, st***********@verizon.net (Stephen J. Fromm) wrote:
I take it I cannot form a container of an array type? For example, stack<string[3]> parentStack;
TIA,
sjfromm You can have containers of arrays,
No, you can't.
but the declaration youv'e posted above is faulty. Youv'e declared a stack where each element is 3 strings. This is fine in principle,
No, it's not. Arrays are not assignable and as such, they cannot be used
as elements of standard containers. The above code should not be
accepted by your C++ compiler.
but probaly what you should do is declare a struct that defines the stack elements, then declare the stack as a stack of those things, like this:
struct STRINGS { string m_Strings[3]; }; // STRINGS
int main() { std::stack<STRINGS> stk; return 0; }
That would work.
"Victor Bazarov" <v.********@attAbi.com> wrote in message news:<vi************@corp.supernews.com>... "Stephen J. Fromm" <st***********@verizon.net> wrote... I take it I cannot form a container of an array type? For example, stack<string[3]> parentStack;
Yes.
Victor,
Yes, I can form, or yes, I cannot form?
John Dibling <dib@substitute_my_full_last_name_here.com> wrote in message news:<n3********************************@4ax.com>. .. On 29 Jul 2003 10:18:57 -0700, st***********@verizon.net (Stephen J. Fromm) wrote:
Thanks for your reply. I take it I cannot form a container of an array type? For example, stack<string[3]> parentStack;
TIA,
sjfromm
You can have containers of arrays, but the declaration youv'e posted above is faulty. Youv'e declared a stack where each element is 3 strings. This is fine in principle, but probaly what you should do is declare a struct that defines the stack elements, then declare the stack as a stack of those things, like this:
Right, that's what I ended up doing.
What I'm curious about is whether I can *directly* define a stack<...>
of an array or not. My compiler decidedly didn't like it. struct STRINGS { string m_Strings[3]; }; // STRINGS
int main() { std::stack<STRINGS> stk; return 0; }
</dib> John Dibling Witty banter omitted for your protection
"Stephen J. Fromm" <st***********@verizon.net> wrote... "Victor Bazarov" <v.********@attAbi.com> wrote in message
news:<vi************@corp.supernews.com>... "Stephen J. Fromm" <st***********@verizon.net> wrote... I take it I cannot form a container of an array type? For example, stack<string[3]> parentStack;
Yes.
Victor,
Yes, I can form, or yes, I cannot form?
Cannot. Arrays do not satisfy the requirements for contained
items: CopyContstructible and Assignable.
Victor
Stephen J. Fromm wrote: What I'm curious about is whether I can *directly* define a stack<...> of an array or not.
Not. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: George Sakkis |
last post by:
Hi all,
I find the string representation behaviour of builtin containers
(tuples,lists,dicts) unintuitive in that they don't call recursively str()
on their contents (e.g. as in Java) :
...
|
by: bartek |
last post by:
Hello,
It is not possible to assign values to, say, a vector<float> due to the
fact that arrays are not assignable.
Theoretically there's a simple workaround which involves wrapping the array...
|
by: slurper |
last post by:
when i do this
vector < vector<int> > p;
later in the code i do things like this:
vector<int> x,y,z;
p.push_back(x);
p.push_back(y);
p.push_back(z);
|
by: Ross A. Finlayson |
last post by:
I'm trying to write some C code, but I want to use C++'s std::vector.
Indeed, if the code is compiled as C++, I want the container to
actually be std::vector, in this case of a collection of value...
|
by: Andrew Ward |
last post by:
Hi,
A third-party container library I use implements its containers using
copy-on-write semantics, making it efficient to return an instance of
the container by value from a function. For...
|
by: Simon |
last post by:
Hi,
I understand what one the differences between std::vector, std::deque and
std::list is,
the std::vector can have data inserted/deleted at the end.
The std::deque can have data...
|
by: paul |
last post by:
Hi,
i want to know if this is better to split a tablespace into several
containers while the database are on san disk.
And how can i configure optimally the values for prefetch and extend ?
thx
|
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...
|
by: Remo D. |
last post by:
I've read with much interest the threads on how to create data
containers in C.
I started thinking if simpler ADT (other than the proposed List) could
be used as a starting point.
What about...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
| |