私はC++が初めてです。g++ コンパイラを使用しています。C++でSTLライブラリの操作を学ぼうとしていました。作業中に、このコードに問題が見つかりました。エラーの理由とエラーの対処方法を説明してください。
#include<iostream>
#include<list>
using namespace std;
typedef struct corrd{
int x;
int y;
}XY;
int main()
{
list<XY> values;
list<XY>::iterator current;
XY data[10];
for(int i=0;i<10;i++)
{
data[i].x = i+10;
data[i].y = i+20;
}
for(int i=0;i<10;i++)
{
values.push_front(data[i]);
}
current = values.begin();
while(current!=values.end())
{
cout<<"X coord:"<<*current->x<<endl;//error: invalid type argument of unary ‘*’ (have ‘int’
cout<<"Y coord:"<<*current->y<<endl;//error: invalid type argument of unary ‘*’ (have ‘int’
current++;
}
}