#include<iostream>
using namespace std;

class Shen_Stock;
class Shang_Stock{
private:
    int general, st, pt;
public:
    Shang_Stock(int g=0, int s=0, int p=0):general(g), st(s), pt(p){}
    friend void showTotal(Shang_Stock s);
    friend int count(Shen_Stock s, Shang_Stock s1);
};

class Shen_Stock{
private:
    int general, st, pt;
public:
    Shen_Stock(int g=0, int s=0, int p=0):general(g), st(s), pt(p){}
    friend void showTotal(Shen_Stock s);
    friend int count(Shen_Stock s, Shang_Stock s1);
};

void showTotal(Shen_Stock s){
    cout'深圳股票总数:'<<s.general+s.st+s.pt<<endl;
}

void showTotal(Shang_Stock s){
    cout'上海股票总数:'<<s.general+s.st+s.pt<<endl;
}

int count(Shen_Stock s, Shang_Stock s1){
    int total = s.general + s.st + s.pt + s1.general + s1.st + s1.pt;
    cout'深圳和上海总共有股票:'<<total<<endl;
    return total;
}

int main(){
    Shen_Stock s(100, 50, 20);
    Shang_Stock s1(200, 30, 10);
    showTotal(s);
    showTotal(s1);
    count(s, s1);
    return 0;
}
C++ 股票程序:深圳和上海股票类实现

原文地址: https://www.cveoy.top/t/topic/nohn 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录