0
我在下面的代码中最后两行发生了什么错误?我收到一个错误:如何打印清单<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:是的,它的确如此。但你不必告诉它。 :) –