0

As I know (in structure) we just use -> operator or*(sth).structfield statement when we are using pointers.is it true? or we use it for structure too? consider following example :

#include <iostream>
static int iiii{};
struct Sth
{
    int id{};
    int age{};
    int exp{};
    int wage{};
} names[20];

void show(Sth (&ref)[20])
{
    std::cout << "sen = " << ((ref + iiii))->age << '\n';//first statement 
    std::cout << "id  = " << (*(ref + iiii)).id << '\n';//second statement 
    std::cout << "exp = " << (*(ref + iiii)).exp << '\n';//third statement 
    std::cout << "wage = " << ref[iiii].wage << '\n';//fourth statement 
    iiii++;
}
int main()
{
    show(names);
}

are these four statements the same?

0 Answers0