I received a pointer to eksepsjonelt?

When you call this constructor returns a pointer to the instance, but when iterating over a vector object, the value returned is as I understand it on the class itself. I went to * operator a pointer, but the compiler politely noted that I have not defined it for the class. I defined it as return this. And still I get the pointer to the base class. Can I somehow protertuyu?
for (auto card : hand)
July 2nd 19 at 17:20
2 answers
July 2nd 19 at 17:22
Taking the address of &. * applies Vice versa to the pointer to the value to obtain. And I need a reference for (auto &card : hand)u Otherwise, you will receive a copy of the card.
for (auto &card : deck)
std::cout << "iteration log "<< *card << "\n";
Something like this? Still not very clear what I did? The iterator returns me the & operator object? *take its address? And as I understand it, taking the address automatically creates a new pointer to the object? - felicita_Homenick commented on July 2nd 19 at 17:25
: U & I * 2 values. In the description of the type do they mean "reference" and "pointer". for (auto &card : deck) means that card is a reference to a vector element. And Yes, iterators there are hidden from you.
A second value when used in expressions: buff(true,*card); *card-to obtain the value at the index card (But it's not a pointer!) Probably need a buff(true,&card); - chaz_Wiso commented on July 2nd 19 at 17:28
To: "the Iterator returns me the & operator object?"
for(<type><variable name> : container)
As I said before & here is not an operator but simply a part of the type name. - chaz_Wiso commented on July 2nd 19 at 17:31
July 2nd 19 at 17:24
This is called value categories.

Literary read.

The type Declaration `int` is the type with the storage value.
The type Declaration `int*` - type storage for the pointer.
The type Declaration `int&` type with the storage of the link.

Any of these forms of records may be used to define the variables, parameters and function results.

for (auto card : hand)
Says that the card is accepted by value, using copying the contents of the iterator. The life time of the card is limited by the space cycle.

for (auto& card : hand)
Says that the card is accepted by reference the contents of the iterator.
When something familiar takes the form of a dragon. Thank you for your response. - felicita_Homenick commented on July 2nd 19 at 17:27

Find more questions by tags C++