首页 > 其他 > 详细

2020/3/16

时间:2020-03-16 23:25:44      阅读:55      评论:0      收藏:0      [点我收藏+]

c++stl视频 string类学习:2小时

技术分享图片

 

 

c++学习第14章,看完了:2小时

#include"iostream"
using std :: cout;
using std :: endl;
///Stack类模板
#ifndef STACKTP_H_
#define STACKTP_H_
template <class Type>
class Stack{
private:
    enum {MAX = 10};
    Type items[MAX];
    int top;
public:
    Stack();
    bool isempty()const;
    bool isfull()const;
    bool push(const Type & item);
    bool pop(Type & item);
};

template <class Type>
Stack<Tyep>:: Stack(){
    top = 0;
}

template <class Type>
bool Stack<Tyep>:: isempty(){
    return top == 0;
}

template <class Type>
bool Stack<Tyep>:: isfull(){
    return top == MAX;
}

template <class Type>
bool Stack<Tyep>:: push(const Type & item){
    if(top < MAX) {
        items[top ++] = item;
        return true;
    } else return false;
}

template <class Type>
bool Stack<Tyep>:: pop(Type & item){
    if(top > 0) {
        item = items[-- top];
        return true;
    } else return false;
}
#endif // STACKTP_H_
///此模板不适合使用指针堆栈
///模板的多功能性
///1,递归使用模板
///2,使用多个类型参数,如pari
///3,默认类型模板参数
///成员模板:模板用在类,结构,模板类的成员。
template <typename T>
class beta {
private:
    template <typename V>
    class hold {
    private :
        V val;
    public:
        hold(V v = 0):val(v){}
        void show()const {cout << val << endl;}
        V Value()const {return val;}
    };
    hold<T> q;
    hold<int>n;
public:
    beta(T t,int i): q(t),n(i){}
    template<typename U>
    U blab(U u, T t){return (n.Value()+q.Value()) * u / t;}
    void Show()const {q.show(); n.show();}
};
int main()
{
    beta<double> guy(3.5,3);
    guy.Show();
    cout << guy.blab(10,2.3) << endl;
    cout << "Done\n";
    return 0;
}
///可以将模板用于参数

 

软件工程网课:2小时

补了昨晚复现一题:1小时

技术分享图片

 

 

蓝书上数学题3题:3小时

技术分享图片

 

 

 技术分享图片

 

 技术分享图片

 

明天任务大体安排:

早上起来9:00-10:00,记一个小时单词;

上午:刷cf1800-2000分题3题;(10:30-13:30)

下午:数据库+stl视频vector类;(14:30-16:10,16:20-18:30)

晚上3个小时,看c++prime第15章;(20:00-22:30)

 

2020/3/16

原文:https://www.cnblogs.com/yrz001030/p/12507381.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!