[Error] request for member 'sort' in 'v', which is of non-class type 'std::list<std::basic_string > [t]'

原因:

主要是v是指针, 但是引用其成员的时候使用了".", 把它当作一般的变量使用了, 这样就会导致这个编译错误.

当然产生这个编译错误的原因还有其他,

例如: 变量虽然定义了, 但是没有在使用的地方之前定义等等

例如:

int t;
cin>>t;
list<string> v[t]{{a,b,c,d},{q,w,e,r}};
for(int i=0;i<t;i++)
{
	v.sort();
}

修改:

int t;
cin>>t;
list<string> v[t]{{a,b,c,d},{q,w,e,r}};
for(int i=0;i<t;i++)
{
	v[i].sort();
}