首页 > 编程语言 > 详细

c++中stl函数的使用

时间:2015-11-06 22:22:09      阅读:273      评论:0      收藏:0      [点我收藏+]
/*#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;
}

 

c++中stl函数的使用

原文:http://www.cnblogs.com/zhangyanguang/p/4943727.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!