【问题标题】:netbeans not showing c++ outputnetbeans 不显示 C++ 输出
【发布时间】:2016-01-11 17:21:50
【问题描述】:

我尝试在谷歌搜索结果上阅读几个不同的帮助论坛结果,但似乎没有一个适用于我的情况。我的 Netbeans 8.0.2 没有显示任何输出。我的程序具有 cout 的功能,而其他程序则具有 cout 的主要功能。什么都没有出现。 Kicker 是没有返回错误。不知道你们是否可以帮助我,但我仍然充满希望。

操作系统: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;
}

【问题讨论】:

    标签: c++ linux netbeans terminal output


    【解决方案1】:

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

    【讨论】:

    • 我展示了代码,以便在代码中有内容的情况下运行它,我只是想涵盖所有基础。其次,是的,我知道我在哪里和窗口(内部终端和外部终端)闪烁的文本持有者。程序没有任何输出。
    猜你喜欢
    • 2016-01-11
    • 2016-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-08
    • 1970-01-01
    相关资源
    最近更新 更多