#include<iostream>
using namespace std;
class CCourse{
private:
long no;
float credit;
static int total_course;
public:
CCourse(long n,float c)
{no=n;
credit=c;
total_course++;
}
CCourse(const CCourse &p)
{no=p.no;
credit=p.credit;
total_course++;
}
~CCourse()
{cout<<"调用析构函数"<<endl;
}
int getTotalCourse()
{return total_course;
}
void print()
{cout<<"课程号:"<<no<<endl;
cout<<"课程学分:"<<credit<<endl;
}
friend int getCourseNo(CCourse &);
friend int operator<(CCourse &,CCourse &);
};
int CCourse::total_course=0;
int getCourseNo(CCourse &p)
{return p.no;
}
int operator<(CCourse &a,CCourse &b)
{if(a.credit<b.credit)
return 1;
else return 0;
}
int main()
{
CCourse stu1(12,3.5);
CCourse stu2(stu1);
CCourse stu3(36,5);
stu1.print();
stu2.print();
cout<<"课程总数:"<<stu1.getTotalCourse()<<endl;
cout<<"课程编号:"<<getCourseNo(stu1)<<endl;
if(stu1<stu3)
cout<<"1"<<endl;
else cout<<"0"<<endl;
system("pause");
return 0;
}