【小宅女编了一下午啊】可是为什么我定义的类不能识别
亲们。我下午用我自己能理解的方法编了编我想要编的程序,无奈我写好了以后报了一大堆错,我认真看了看大部分就是说我定义的类它觉得不对,或者是识别别不了,求懂得大牛牛小牛牛帮我看看吧!!猜测这个对懂得人应该是一个很小的问题吧。求解救!!爱你们!我最后一点点分也散在这里吧。。不够去别的帖子回复吧我把我写的.h&.cpp贴出来
类定义头文件
程序代码:
#include <iostream> using namespace std; class fund { public: fund(){}; private: }; class motherfund: public fund { public: motherfund(double netvalue_) : netvalue(netvalue_) {}; private: double netvalue; }; class umbrellafund : public fund { public: umbrellafund(double netvalue_,double stockprice_) : netvalue(netvalue_),stockprice(stockprice_) {}; private: double netvalue; double stockprice; };
操作函数头文件
程序代码:
#include <iostream> #include "classfund.h"//为什么我include了这个头文件它识别不到呢??? using namespace std; double LOFarbitrage(const motherfund& motherfund_,const umbrellafund& umbrellafundA_,const umbrellafund& umbrellafundB_,int shares_)
操作函数具体说明.CPP
程序代码:
#include <iostream> #include "classfund.h"//为什么我include了这个头文件它识别不到呢??? using namespace std; double LOFarbitrage(const motherfund& motherfund_,const umbrellafund& umbrellafundA_,const umbrellafund& umbrellafundB_,int shares_) {double Pr=0.015; double Rr=0.005; double Br=0.0005; double condition1=umbrellafundA_.stockprice+umbrellafundB_.stockprice)*(1-Br)-(2*motherfund_.netvalue*(1+Pr); //[1] (Ma+Mb)*x*(1-br)> 2x*Nm*(1+Pr): double conditon2=umbrellafundA_.stockprice+umbrellafundB_.stockprice)*(1-Br)-(2*motherfund_.netvalue*(1+Rr); //[2] (Ma+Mb)*x*(1-br)< 2x*Nm*(1+Rr): if (condition1>0) return contion1*shares_ else if (condition2<0) return condition2*shares_ else return 0; }
我的主程序
程序代码:
int main() {double mothernetvalue;//输入需要的五个值,具体需要的输入函数没写 double umbrellavalueA,umbrellapriceA; double umbrellavalueB,umbrellapriceB; int theshares;//用多少份来进行套利 cout<<"输入母基金净值"<<endl; cin>>mothernetvalue; cout<<"输入子基金A净值"<<endl; cin>>umbrellavalueA; cout<<"输入子基金A市价"<<endl; cin>>umbrellapriceA; cout<<"输入子基金B净值"<<endl; cin>>umbrellavalueB; cout<<"输入子基金B市价"<<endl; cin>>umbrellapriceB; cout<<"每次套利多少份"<<endl; cin>>theshares; motherfund the_motherfund(mothernetvalue); umbrellafund umbrellaA(umbrellavalueA,umbrellapriceA);//建立需要的五个变量 umbrellafund umbrellaB(umbrellavalueB,umbrellapriceB); double thepayoff=LOFarbitrage(the_motherfund,umbrellaA,umbrellaB,theshares)//代入这个函数计算有没有套利,套利出来是多少,为了简便没有的时候设为0 if (thepayoff==0) cout<<"此时无套利机会"<<endl; if (thepayoff!=0) cout<<"此时有套利机会,可以套利"<<thepayoff<<endl; }