Hmm.. So why don't you use std:: in arrays for example?
Got any good link if you want to learn "a->b is equivalent to (*a).b." a little better?
Hmm.. So why don't you use std:: in arrays for example?
Got any good link if you want to learn "a->b is equivalent to (*a).b." a little better?
>> Hmm.. So why don't you use std:: in arrays for example?
They aren't in a namespace by default for the same reason a vanilla class isn't in a namespace by default. Arrays are a language construct, not a part of the standard libraries.
>> Any good link
Well it's probably in a C++ book near the pointers chapter.
The jist is as you heard, a is a pointer to a struct, class or union, and b is a member.
a->b dereferences a before accessing b.
(*a).b is the same thing, but the syntax is a bit convoluted, yet necessary, because dereferencing has a lower precedence then the dot operator; that is, you cannot access members of a pointer's type without dereferencing a pointer first.
Get a book and look up a C++ operator precedence chart.
Because arrays is not in the std namespace.
I suggest you get a good book. Those belong to pointers and merely understanding the syntax is not enough. You need to know how pointers work in general.Got any good link if you want to learn "a->b is equivalent to (*a).b." a little better?
A book would help on the namespace issue, as well.
Thank you all.
I would be glad to know, for educational purposes, how you combine your suggestions about maps (ID), with that struct and vector?Code:struct data { string name; string title; string author; }; vector <data> books;
Ask yourself how data will be used and then choose or implement the design that fascilitates this use.
*thisGot any good link if you want to learn "a->b is equivalent to (*a).b." a little better?
How would you store the data inside a .txt file, so you can request data from the .txt file that is already there, or store additional data?
How would you store string data inside a .txt file, so you can request data from the .txt file that is already there, or store additional data?