日韩精品福利免费观看高清,综合亚洲国产2020,99热只有精品这里,国产精品久久久久久久福利

    1. <address id="kobe1"></address>
      
      
      <td id="kobe1"><tbody id="kobe1"><listing id="kobe1"></listing></tbody></td>

        中南大學c++實踐報告

        發(fā)布時間:2017-07-12  編輯:沈舒文 手機版

          book(string b_id,string b_n,string au,string pu,double pr);

          void display();

          string getbook_ID();

          string getbook_name();

          string getauther();

          string getpublishing();

          double getprice();

          };

          book::book(string b_id,string b_n,string au,string pu,double pr)

          {

          book_ID=b_id;

          book_name=b_n;

          auther=au;

          publishing=pu;

          price=pr;

          }

          book::book()

          {

          book_ID="";

          book_name="";

          auther="";

          publishing="";

          price=0;

          }

          void book::display()

          {

          cout<<"書號:"<

          cout<<"書名:"<

          cout<<"作者:"<

          cout<<"出版社:"<

          cout<<"定價:"<

          }

          string book::getbook_ID()

          {return book_ID;}

          string book::getbook_name()

          {return book_name;}

          string book::getauther()

          {return auther;}

          string book::getpublishing()

          {return publishing;}

          double book::getprice()

          {return price;}

          //book.h 結(jié)束

          //strclass.h 文件結(jié)束

          #include "string.h"

          class string

          {

          friend ostream& operator<<(ostream& S,const string& Str);

          friend istream& operator>>(istream& S,string& Str);

          public:

          string();

          string(const string& Str);

          void operator=(const string& Str);

          ~string();

          string(char * p);

          private:

          short m_Length;

          char * m_Data;

          };

          string::string()

          {

          m_Length=1;

          m_Data=new char [m_Length];

          memcpy(m_Data,"",m_Length);

          };

          string::string(const string& Str)

          {

          m_Length=Str.m_Length;

          m_Data=new char [m_Length];

          memcpy(m_Data,Str.m_Data,m_Length);

          };

          string::string(char *p)

          {

          m_Length=strlen(p)+1;

          m_Data=new char[m_Length];

          memcpy(m_Data,p,m_Length);

          };

          void string::operator=(const string& Str)

          {

          if(&Str!=this)

          {

          delete [] m_Data;

          m_Length=Str.m_Length;

          m_Data=new char [m_Length];

          memcpy(m_Data,Str.m_Data,m_Length);

          }

          return;

          };

          string::~string()

          {delete [] m_Data;};

          ostream& operator<<(ostream& S,const string& Str)

          {

          short i;

          for(i=0;i

          S << Str.m_Data[i];

          return S;

          };

          istream& operator >> (istream& S,string& Str)

          {

          const short BUFLEN=256;

          char Buf[BUFLEN];

          memset(Buf,0,BUFLEN);

          if(S.peek()=='\n')

          S.ignore();

          S.getline(Buf,BUFLEN,'\n');

          Str=Buf;

          return S;

          };

          //strclass.h結(jié)束

          //buy_book.cpp開始

          #include

          #include "strclass.h"

          #include "buyer.h"

          #include "book.h"

          void main()

          {

          int i=0,buyerid,flag;

          book *c[2];

          layfolk b1("王林",1,"武漢",0);

          honoured_guest b2("張麗",2,.6,"長沙",0); //

          member b3("張強",3,5,"廣州",0);

          buyer *b[3]={&b1,&b2,&b3};

          book c1("7-302-04504-6","計算機二級輔導","張林","清華",25);

          book c2("7-402-03388-9"," 數(shù)據(jù)結(jié)構(gòu)","許桌群","北大",20);

          c[0]=&c1;

          c[1]=&c2;

          cout<<"購書人信息:\n\n";

          for(i=0;i<3;i++)

          b[i]->display();

          cout<<"\n圖書信息:\n\n";

          for(i=0;i<2;i++)

          c[i]->display();

          cout<<"\n\n請輸入購書人編號:";

          cin>>buyerid;

          flag=0;

          for(i=0;i<3;i++)

          if(b[i]->getid()==buyerid){flag=1;break;}

          if(!flag){cout<<"編號不存在"<

          else

          {

          b[i]->setpay(c[0]->getprice());

          b[i]->setpay(c[1]->getprice());

          cout<getpay()<<"\n\n";

          }

          }

          //buy_book.cpp文件結(jié)束

          運行結(jié)果如下:

          實訓心得:

          轉(zhuǎn)眼,C++一周的實訓已經(jīng)結(jié)束了,在這一周的過程中,通過上機練習C++編程,深切的體會到了編程的樂趣,在做題的過程中,不僅提高了我動手實踐的能力,我懂得了它不是一個人的任務,是大家共同努力的結(jié)果。

          不過我也真正的認識到,要學好C++理論是基本,要想更好的,更快的有所突破還是要通過上機練習。

          在此次實訓中,我也看到了許多自己的不足,不僅是知識上的,還有思考能力等都需要提高,再編程過程中,思維是占主要的。所以不斷的編程,是提高自己能力的途徑。

          在此更要感謝老師對我們的孜孜不倦的教導!


        123
        相關推薦

        最熱文章榜Hot  Top