2020/3/9

莫队?又或是树状数组吧。卡莫队,还放莫队题目集,玩心态呀:1.5小时

 cf:2小时

软件工程:2小时

英语单词:1小时

复习了C++12章,看了13章一半左右:https://www.cnblogs.com/yrz001030/p/12453076.html

3.5个小时

#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;///不能在类中初始化静态成员

StringBad :: StringBad(const char *s)
{
    len = strlen(s);
    str = 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;
    return os;
}


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 关键字至关重要,使用了:程序将根据引用或指针指向的对象的类型来选择方法
    ///未使用,则程序将根据引用类型或指针的类型来选择方法。(派生类和基类重载了方法)
    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;}
};

猜你喜欢

转载自www.cnblogs.com/yrz001030/p/12453085.html