c++中stl函数的使用
/*#include <iostream> #include <list> using namespace std; class ListTest { public: protected: private: }; void main(){ list<int> seq(8,9); list<int> ::const_iterator i=seq.begin(); int count=seq.size(); while(count){ cout<<count<<":"<<*i<<endl; count--; i++; } }*/ #include <iostream> using namespace std; struct Teacher{ char name[64]; int age; }; int getTeacher(Teacher **p){ Teacher *tmp=NULL; if(p==NULL){ return -1; } tmp=(Teacher *)malloc(sizeof(Teacher)); if (tmp ==NULL) { return -2; } tmp->age=33; *p=tmp; tmp->age=89; static int i=0; i=7; } int getTeacher1(Teacher* &tmp){ if(tmp==NULL){ return -1; } tmp->age=36; } void main(){ Teacher *pt1=NULL; getTeacher(&pt1); cout<<"age:"<<pt1->age<<endl; getTeacher1(pt1); cout<<pt1->age<<endl; }