zoukankan      html  css  js  c++  java
  • 2020/3/16

    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
    ";
        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)

  • 相关阅读:
    移动前端开发之viewport的深入理解
    javascript的事件监听与捕获和冒泡
    AngularJS服务中serivce,factory,provider的区别
    使用shadow dom封装web组件
    Web Components之Custom Elements
    javascript 布尔类型值判断
    requestAnimationFrame()
    二十周年感言
    文件上传实例
    jhipster技术栈研究
  • 原文地址:https://www.cnblogs.com/yrz001030/p/12507381.html
Copyright © 2011-2022 走看看