zoukankan      html  css  js  c++  java
  • 构造函数与析构函数(其中有两点值得学习)

    // 构造函数与析构函数.cpp : 定义控制台应用程序的入口点。
    //要学习的两点:
    //要想表现出析构函数,必须在对象外面加大括号!!
    //  while (cin.get() != ' ')   num++;
    #include "stdafx.h"
    #include<iostream>
    using namespace std;
    class Count
    {
    public:
        Count();
        ~Count();
        void process();
    private:
        int num;
    };

    Count::Count()
    {
        num = 0;
    }

    Count::~Count()
    {
        cout << "The length of sentence:" << num << endl;

    }

    void Count::process()
    {
        while (cin.get() != ' ') //this is need to study!!
            num++;
    }
    int main()
    {
        {
            Count c;
            c.process();
        }//要想表现出析构函数,必须在对象外面加大括号!!
        system("pause");
        return 0;
    }
    捕获

  • 相关阅读:
    前端-----盒子模型
    跨域
    DRF的分页
    DRF的权限和频率
    DRF 版本和认证
    DRF的视图和路由
    APIView和View的区别
    Serializers序列化组件
    RESTful
    Vuex以及axios
  • 原文地址:https://www.cnblogs.com/summercloud/p/5522122.html
Copyright © 2011-2022 走看看