精华内容
下载资源
问答
  • stock

    2015-05-19 21:11:28
    //stock.h #include class stock { public: stock(); stock(const std::string& co,long n=0,double pr=0.0); stock(const stock& s); ~stock(); void buy(long num,double price); void sell(long num,...
    //stock.h
    
    #include <string>
    
    class stock
    {
    public:
    	stock();
    	stock(const std::string& co,long n=0,double pr=0.0);
    	stock(const stock& s);
    	~stock();
    	void buy(long num,double price);
    	void sell(long num,double price);
    	void update(double price);
    	void show()const;
    	const stock& topval(const stock& s)const;
    	stock& operator=(const stock& s);
    private:
    	static int num;
    	std::string company;
    	int shares;
    	double share_val;
    	double total_val;
    	void set_tot()
    	{
    		total_val=shares*share_val;
    	}
    };



    //stock.cpp
    
    #include <iostream>
    #include "stock.h"
    
    int stock::num=0;
    
    stock::stock():company("no name"),shares(0),share_val(0.0),total_val(0.0){}
    stock::stock(const std::string& co,long n,double pr):company(co),shares(n),share_val(pr){set_tot();}
    stock::stock(const stock& s)
    {
    	company=s.company;
    	shares=s.shares;
    	share_val=s.share_val;
    	total_val=s.total_val;
    }
    stock::~stock()
    {
    	std::cout<<std::endl<<++num<<std::endl;
    }
    void stock::buy(long num,double price)
    {
    	shares+=num;
    	share_val=(total_val+num*price)/shares;
    	set_tot();
    }
    void stock::sell(long num,double price)
    {
    	shares-=num;
    	share_val=(total_val-num*price)/shares;
    	set_tot();
    }
    void stock::update(double price)
    {
    	share_val=price;
    	set_tot();
    }
    void stock::show()const
    {
    	using std::cout;
    	using std::ios_base;
    	using std::endl;
    	ios_base::fmtflags orig=cout.setf(ios_base::fixed,ios_base::floatfield);
    	std::streamsize prec=cout.precision(3);
    
    	(cout<<"Company: "<<company<<endl
    		<<"Shares: "<<shares<<endl
    		<<"Share Price: $"<<share_val<<endl).precision(2);
    	cout<<"Total Worth: $"<<total_val<<endl;
    	cout.setf(orig,ios_base::floatfield);
    	cout.precision(prec);
    }
    const stock& stock::topval(const stock& s)const
    {
    	return total_val>s.total_val?*this:s;
    }
    
    stock& stock::operator=(const stock& s)	//"="必须是成员函数
    {
    	if(this!=&s)
    	{
    		company=s.company;
    		shares=s.shares;
    		share_val=s.share_val;
    		total_val=s.total_val;
    	}
    	return *this;
    }



    //stock_test.cpp
    
    #include <iostream>
    #include "stock.h"
    
    int main()
    {
    	stock stock1("E",100,10);
    	stock1=stock("F",200,20);
    	stock stocks[4]=	//对象数组,首先使用默认构造函数创建数组元素,然后花括号中的各构造函数创建临时对象,使用赋值运算符赋值.
    	{
    		stock("A",12,20.0),
    		stock("B",200,2.0),
    		stock("C",130,3.25),
    		stock("D",60,6.5)
    	};
    	stock top;
    	for(int i=0;i<4;++i)
    	{
    		stocks[i].show();
    		top=top.topval(stocks[i]);
    	}
    	top.show();
    	while(std::cin.get()!='\n');
    	return 0;
    }
    

    展开全文
  • Stock-源码

    2021-03-22 15:54:07
    Stock
  • stock-源码

    2021-03-15 07:57:16
    stock
  • Astock

    2019-10-25 03:25:32
    Astock
  • Stock4j 使用Yahoo Finance API构建的Java股票API 入门 从下载最新版本 将其作为依赖项添加到您的Java项目中 用法 创建股票 要创建股票,您必须提供一个名称。 例如,我将使用AAPL进行演示。 Stock stock = new ...
  • stock system

    2013-02-20 04:39:42
    stock system
  • stock feedback

    2014-07-17 22:36:22
    help increase stock twitter feedback count
  • stock file.zip

    2021-08-18 20:14:44
    stock file.zip
  • stock alert

    2012-01-05 19:12:07
    windows system destk stock alert green free stock
  • django_stockStock Tracker Django Web应用程序
  • StockMarket-源码

    2021-03-08 02:14:12
    StockMarket
  • The interaction between stock price process and market news has been widely analyzed by investors on different markets. Previous works, however, focus either on market news purely as exogenous factors...
  • STOCK TRANSFER

    2010-05-20 09:06:13
    STOCK TRANSFERSTOCK TRANSFERSTOCK TRANSFERSTOCK TRANSFER
  • stock_photos:使用React和Unsplash Stock Photos API构建的webapp
  • flutter demo stock

    2016-08-28 11:23:13
    flutter编译好的demo stock 源码在https://flutter.io可以下载
  • stock 简易的股票量化交易系统
  • Stock Exchange

    2017-07-23 12:01:48
    Each data set in the file stands for a particular set of stock prices. A data set starts with the length L (L ≤ 100000) of the sequence of numbers, followed by the numbers (a number fits a long ...
  • c#stock通信

    2015-11-17 10:19:04
    c#stock通信,提供客户端和服务端的通信
  • stock_viewer-源码

    2021-07-11 19:39:46
    stock_viewer
  • news stock.zip

    2019-12-13 16:45:34
    kaggle news stock 简单文本特征处理 数据集。完整数据集。这是个文本分类相关的数据集
  • stock_public-源码

    2021-04-12 21:13:27
    stock_public
  • stock_platform-源码

    2021-03-30 16:17:46
    stock_platform
  • stock_server-源码

    2021-03-29 17:31:07
    stock_server
  • stock_golang-源码

    2021-03-27 11:45:29
    stock_golang
  • beer-stock-源码

    2021-03-27 06:24:37
    beer-stock
  • Stock-Management-源码

    2021-03-27 05:20:12
    Stock-Management
  • stock_mining-源码

    2021-03-26 11:26:11
    stock_mining

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 94,240
精华内容 37,696
关键字:

stock