0
以下のコードの最後の2行で何が間違っていますか?私は、エラーメッセージが表示されます。リストの印刷方法<class*> ls?
request for member
‘name’
in‘t.std::_List_iterator<_Tp>::operator* [with _Tp = a*]()’
, which is of non-class type‘a*’
#include <dlfcn.h>
#include <iostream>
#include "/home/developer/Desktop/MsgSphSDK1/test1_sdk/libsdk_MS.hpp"
#include <list>
#include <typeinfo>
#include <string>
using namespace std;
class a
{
public:
string name;
int age;
};
int main()
{
a* l = new a();
l->name = "me";
l->age = 1;
list<a*> ls;
list<a*>::iterator t;
for (t = ls.begin(); t != ls.end(); ++t)
cout << (*t).name << endl;
}
なぜ 'main()'が何かを返さないのですか? – Donotalo
@Donotalo:それは必要ないので。 – Xeo
@ Xeo:はい、そうです。しかし、あなたはそれを伝える必要はありません。 :) –