2020/3/9

Mo team? Fenwick tree or another bar. Kamo team, but also put Mo team title set, play mentality ah: 1.5 hours

 

 cf: 2 Xiaoshi

Software Engineering: 2 hours

English words: 1 hour

Review the C ++ 12 chapter, read chapter 13 about half: https://www.cnblogs.com/yrz001030/p/12453076.html

3.5 hours

#include"stdio.h"
#include"string.h"
#include"iostream"
#include"algorithm"
using namespace std;

class StringBad{
private:
    char *str;
    int len;
    static int num_strings;
public:
    StringBad(const char *s);
    StringBad();
    ~StringBad();
    friend std::ostream & operator << (std :: ostream & os,const StringBad &st);
};

int StringBad :: num_strings = 0; /// can not initialize static member class

StringBad :: StringBad(const char *s)
{
    len = strlen (s);
    p = new char [len + 1];
    strcpy(str,s);
    num_strings ++;
    cout << num_strings << ":\"" << str
    << "\" object created\n";
}
StringBad::StringBad()
{
    len = 4;
    str = new char [4];
    strcpy(str,"c++");
    num_strings ++;
    cout << num_strings << ":\"" << str
    << "\" default object created\n";
}
StringBad :: ~StringBad()
{
    cout << "\"" << str << "\" object deleted,";
    -- num_strings;
    cout << num_strings << " left\n";
    delete [] str;
}

std:: ostream & operator << (std :: ostream &os,const StringBad &st)
{
    os << st.str;
    the return;
}


void callme1(StringBad &);
void callme2(StringBad);

int main ()
{
    using std :: endl;
    StringBad headline1("Celery Stalks at Midnight");
    StringBad headline2("Lettuce Prey");
    StringBad sports("Spinach Leaves Bow1 for Dollars");
    cout << "headline1: " << headline1 << endl;
    cout << "headline2: " << headline2 << endl;
    cout << "sports:" << sports << endl;
    callme1 (headline1);
    cout << "headline1: " << headline1 << endl;
    callme2 (headline2);
    cout << "headline2: " << headline2 << endl;
    cout << "Initialize one object to another: \n";
    StringBad sailor = sports;
    cout << "sailor: " << sailor << endl;
    cout << "Assign one object to another: \n";
    StringBad knot;
    knot = headline1;
    cout << "knot:" << knot << endl;
    cout << "End of main()\n";
    return 0;
}

void callme1(StringBad &rsb)
{
    cout << "String passed by reference: \n";
    cout << "    \"" << rsb << "\"\n";
}
void callme2(StringBad sb)
{
    cout << "String passed by value: \n";
    cout << "    \"" << sb << "\"\n";
}

 

#include"stdio.h"
#include"string.h"
#include"algorithm"
using namespace std;

class Brass{
private:
    enum {MAX = 35};
    char fullName[MAX];
    long acctNum;
    double balance;
public:
    Brass(const char *s = "Nullbody",long an = -1,double bal = 0.0);
    void Deposit(double amt);
    virtual void Withdraw(double amt);
    /// virtual keyword is essential to use: the program will be selected according to the type of method reference or pointer to the object
    /// not used, the program will be selected according to the method of the type of a reference or pointer. (Base class and derived classes override method)
    double Balance()const;
    virtual void ViewAcct()const;
    virtual ~Brass(){}
};
///Brasss plus Account Class
class BrassPlus: public Brass{
private:
    double maxLoan;
    double rate;
    double owerBank;
public:
    BrassPlus(const char *s = "Nullbody",long an = -1,double bal = 0.0,double m1 = 500,double r = 0.10);
    BrassPlus(const Brass & ba,double m1 = 500,double r = 0.1);
    virtual void ViewAcct()const;
    virtual void Withdraw(double amt);
    void ResetMax(double m){maxLoan = m;}
    void ResetRate(double r){rate = r;}
    void ResetOwes(){owesBank = 0;}
};

 

Guess you like

Origin www.cnblogs.com/yrz001030/p/12453085.html
3/9