繁体   English   中英

netbeans不显示c ++输出

[英]netbeans not showing c++ output

我尝试阅读有关Google搜索结果的几种不同的帮助论坛结果,但似乎没有一种适用于我的情况。 我的Netbeans 8.0.2没有显示任何输出。 我的程序中具有cout的功能,而其他程序则具有cout的功能。 什么都没有出现。 提示是没有返回错误。 不确定你们是否能帮助我,但我仍然充满希望。

操作系统: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 您确定这不是您的问题吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM