当我使用vs 2017运行程序时,操作结果将闪回

时间:2019-04-13 15:12:56

标签: visual-studio-2017

我知道如何解决该问题,(在“ return 0”前面添加代码“ system(“ pause”)”)

enter image description here

但是我只是不知道vs发生了什么事?

#define _CRT_SECURE_NO_WARNINGS  
#include <iostream>
#include <ctime>
#include <string> 
using namespace std;

class Date
{
public:
    Date(int, int, int, int);
    ~Date()
    {
        cout << "Thanks you !" << endl;
    }
    void print() const;
private:
    int year;
    int month;
    int day;
    int day1;
    const string Month[12] = { "January","February","March","April","May","June","July","August","September","October","November","December" };
};

Date::Date(int y = 1900, int m = 1, int d = 1, int d1 = 1)
{
    year = y;
    month = m;
    day = d;
    day1 = d1;
}

void Date::print() const
{
    cout << "DDD YYYY: " << day1 << "  " << year << endl;
    cout << "MM/DD/YYYY: " << month << "/" << day << "/" << year << endl;
    cout << Month[month - 1] << " " << day << " " << year << endl;
}

int main()
{
    time_t t;
    t = time(NULL);
    struct tm *local = localtime(&t);
    int y = local->tm_year + 1900;
    int m = local->tm_mon + 1;
    int d = local->tm_mday;
    int d1 = local->tm_yday;
    Date date(y, m, d, d1);
    date.print();
    //system("pause");

    return 0;
}

0 个答案:

没有答案