📄 student.cpp
字号:
#include<iostream>
#include<string>
#include"student.h"
using namespace std;
void Stud::setage(int a)
{
this->age=a;
}
Stud::~Stud()
{
cout<<"call destructor"<<this<<endl;
}
//Stud(){cout<<"call default constructor."<<this<<endl; countp++;}
Stud::Stud(Stud& s)
{
this->name=s.name;
this->age=s.age;
this->sex=s.sex;
this->sc1=s.sc1;
this->sc2=s.sc2;
cout<<"call copy constructor."<<this<<endl;
countp++;
}
float Stud::getsc2()
{
return sc2;
}
// Stud::Stud(string n="wangjian",int a=23,string s="boy",float s1=100,float s2=100);
void Stud::showcount()
{
cout<<"the total number of the students is:"<<countp<<endl;
//sc1=6;
}
float Stud::getsc1() const
{
//sc1+=20;
return sc1;
}
float Stud::getsc1()
{
sc1+=20;
return sc1;
}
int Stud::countp=0;
void Stud::show()
{
cout<<name<<age<<sex<<sc1<<sc2<<endl;
}
Stud::Stud(string n,int a,string s,float s1,float s2)
{
this->name=n;
this->age=a;
this->sex=s;
this->sc1=s1;
this->sc2=s2;
cout<<"call normal constructor"<<this<<endl;
//this->countp++;
}
Stud generate()// generate a object of class Stud and return it.
{
return Stud("wangjian",23,"boy",100,100);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -