Netbeans不显示c++输出

netbeans not showing c++ output

本文关键字:输出 c++ 显示 Netbeans      更新时间:2023-10-16

我试着在谷歌搜索结果上阅读了几个不同的帮助论坛结果,但似乎没有一个适用于我的情况。我的Netbeans 8.0.2没有显示任何输出。我有一些程序在函数中有cout而在主程序中有cout。什么都没有。问题是没有返回错误。我不知道你们是否能帮我,但我仍然抱有希望。

OS: Ubuntu 14.04 LTS

Netbean版本:8.0.2

下面是一个示例代码:
#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
class calender
{
private:
    int month;
    int day;
    int year;
public:
    void getdate(int m, int d, int y);
    void showdate();
};
void calender::getdate(int m, int d, int y){
        m=month;
        d=day;
        y=year;
}
void calender::showdate(){
        cout<<"The date is:"<<setfill('0')<<setw(2)<<month<<"/"<<setw(2)<<day
                <<"/"<<setw(2)<<year<<endl;
}
int main() {
    int month, day, year;
    char contin;
    while (contin=='y'){
    calender c1;
    cout<<"What is the month:  ";
    cin>>month;
    cout<<"What is the day:  ";
    cin>>day;
    cout<<"What is the year:  ";
    cin>>year;
    c1.getdate(month,day,year);
    c1.showdate();
    cout<<"Do you want to continue(y/n): ";
    cin>>contin;
    }
    return 0;
}

编辑:我真笨——正如所写的那样,您的代码无论如何都不会有任何输出。您从未初始化变量contin,因此while循环中的条件语句永远不会计算为true。你确定这不是你的问题吗?