I don't understand what clarification is needed. Please explain your concerns. From my viewpoint, I have asked a question which conforms to the technical area being addressed, I have explained my confusion, I have given an example which illustrates my issues, and I have elaborated on the diagnostic messages received. The respondents to this question understood my question, the example, and the diagnostic messages in sufficient detail that they were able to respond appropriately and to correct my errors and misconceptions. In what way can this dialog be made more pungent with an appropriately asked question?
@Ruzihm stated that there were no lists, I suppose in my example. I would like to explain why that statement is erroneous. Years ago there was a LIFO stack and a FIFO stack. We call a LIFO stack a 'stack', and a FIFO stack a 'queue'. In England, the line standing before, e.g., a theater box office is a queue, and the pigtails that Chinese men wore after the Mongol conquest of China is also a queue. It all depends on context.
The complaint that there are no 'lists' probably extends from the notion that there are no instantiations of <list>
objects. But such objects are more appropriately called a linked list, a linked list of linked lists is known as a graph, see e.g. Gnu gSlip documentation. Clearly linked lists were not involved.
In C/C++ it is possible to form a multiple-dimensional array which are non-rectangular. Such objects have historically been known as a 'list of lists', and not an 'array of arrays'. The reason is clear, a 'list' is an object containing items, in programmatic terms, accessible by an index, as in list[index]. This is not to say that a linked list, a.k.a., <list>
, is not also a 'list', but normal convention makes more explicit that a <list>
is a linked list.
If the question is changed to 'array of arrays', then the examples make little sense. In terms likened to using <list>
, there are no <array>
's. So whatever criticism exists for using 'list of lists' is retained and relevant in using 'array of arrays'. If one is inappropriate, the other is also.
The answer given, i.e., use a vector of vectors, is to the point, accurate, and responds correctly to the question about a list of lists. As stated in documentation concerning vectors, for example on https://cpluscplus.com, a vector is a list where elements are accessible by index. In this context, a vector of vectors is a particular list of lists, more particularly, a list of lists which are jagged and not an array of arrays which must be rectangular.
I believe any statement saying that the example posted to explain my quandry in forming a list of lists is inappropriate shows some misunderstanding of software practice and jargon. The question is correctly formed and the examples correctly address the question.
If this question is deleted, or in other ways made non-accessible, then you support an ill-formed statement concerning the question. I hope that this is not done.
MSVS 16.9.1
I've created a list of lists of strings. I have difficulty getting either the size of the list of lists or the size of string array in the list. I get conflicting error messages and I don't know how to resolve them.
# include <string>
using namespace std;
static const string x[3] = { "a", "b", "c" };
static const string y[] = { "a", "b", "c" };
static const string* z[] = { x, y };
int xSize = x->size();
int ySize = y->size();
int zSize = z.size(); // expression must have class type
int zpSize = z->size(); // expression must have pointer-to-class type
int xzSize = z[0]->size();
int yzSize = z[1]->size();
The error descriptions are:
Expression must have class type error in C++ Last Updated : 14 Jan, 2021 The expression must have class type is an error that is thrown when the dot (.) operator is used to access an object’s properties, is used on pointers to objects.
And:
Well here we have a problem. My MSVS uses bing to do a web search for the answer, and none of the answers are as pointed as the one above. The gist is that the object must be a pointer and it is not.
The upshot is that neither zpSize nor zSize work and the errors given are contradictory. I'm stumped.