实验三类与对象

#include #include #include using namespace std; class Stock{ public: Stock(){count++;} Stock(int a,int b,int c,int d,int e) { this->num=a; this->todaymax=b; this->todaymin=c; this->todaybegin=d; this->todayend=e; count++; } ~Stock() {count--;} void Assign_stack(Stock &c) {this->num=c.num; this->todaymax=c.todaymax; this->todaymin=c.todaymin; this->todaybegin=c.todaybegin; this->todayend=c.todayend; } void display() { cout<<"交易日 "<num<<" "; cout<<"当天最高 "<todaymax<<" "; cout<<"当天最低 "<todaymin<<" "; cout<<"当天开盘 "<todaybegin<<" "; cout<<"当天收盘 "<todayend<<" "<c.todayend;} int Stock::count=0; int main() { Stock a[5]; Stock *p; Stock b(1,2,3,4,5); //cout<show(); b.display(); Stock c(2,3,4,5,6); p->show(); Stock d(3,4,5,6,7); Stock e(4,5,6,7,8); p->show(); Stock f(5,6,7,8,9); a[0].Assign_stack(b); p->show(); a[1].Assign_stack(c); a[2].Assign_stack(d); a[3].Assign_stack(e); a[4].Assign_stack(f); if(!cmp(a[0])) cout<<"profit \n"; else cout<<"not profit \n"; for(int i=0;i<5;++i) a[i].display(); Stock *point=a; for(;point!=&a[4];++point) cout<<"今天的涨幅为......"<increase(*(point+1))<

你可能感兴趣的:(实验三类与对象)