问题解决了,把 #include <string.h> 改写成 #include <string> 就行了
#include <iostream>
#include <string>
#include "tinystr.h"
#include "tinyxml.h"
#include <vector>
#include "Text.h"
#include <list>
#include <algorithm>
using namespace std;
class CTest
{
public:
virtual void prn(){cout<<"text"<<endl;};
};
class CTestText : public CTest
{
public:
void prn(){cout<<"CTestText"<<endl;};
};
void getmemory(char **pr)
{
*pr = (char *)malloc(20);
}
void getbuffer()
{
char *buffer = NULL;
getmemory(&buffer);
}
int main()
{
list<string> listText;
list <string>::iterator itTemp;
listText.push_back("who am i");
listText.push_back("hello world");
listText.push_back("james");
listText.push_back("windows mobile");
listText.push_front("james push_fornt");
listText.push_front("windows mobile push_fornt");
listText.push_front("the first one");
itTemp = find(listText.begin(), listText.end(), "james");
if (itTemp == listText.end())
{
cout<<"no find"<<endl;
}
else
{
cout<< *itTemp<<endl;
}
for (itTemp = listText.begin(); itTemp != listText.end(); ++itTemp)
{
cout<<(*itTemp)<<endl;
}
// cout<<(itTemp = listText.begin(); itTemp != listText.end(); ++itTemp);
vector<CTest*>pTest;
for(int i = 0; i < 10; i++)
{
if(i%2==0)
{
CTest *p = new CTestText();
pTest.push_back(p);
//pTest.push_back("who am i");
}
else
{
CTest *p = new CTest();
pTest.push_back(p);
//pTest.push_back("hello world");
}
}
for( vector <CTest*>::iterator it = pTest.begin(); it != pTest.end(); ++it )
{
(*it)->prn();
}
return 0;
}