Re: problems with pointers and structs
* pcnate@gmail.com:
Here is my object instance declaration
Books book[100];
I know I don't want to use vectors right now, I just need to learn how
to point to this in a way to change my values
Well, if you don't want the easy, professional way, but rather the
difficult, unprofessional way, i.e. as many hurdles and problems and
bugs as possible, there's not much advice to give except delve into it
and try the most difficult and hard to grok you can think of first: that
should presumably give you enough problems.
Otherwise, replace that declaration with
std::vector<Book> books( 100 );
Note the placement of the "s": the type Book describes a single book
(not plural), wheras the variable is a collection of book (plural).
Now you can write e.g.
std::cout << books.at(3).title << std::endl;
And you'll discover that that magic number 100 is completely
meaningless, because the vector, as opposed to the raw array, can be
very easily resized to accomodate any number of books.
--
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?