gpt4 book ai didi

c++ - netbeans 不显示 C++ 输出

转载 作者:太空宇宙 更新时间:2023-11-04 13:04:19 24 4
gpt4 key购买 nike

我试过在谷歌搜索结果中阅读几个不同的帮助论坛结果,但似乎没有一个适用于我的情况。我的 Netbeans 8.0.2 没有显示任何输出。我有一些程序在函数中有 cout,而其他程序在 main 中有 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;
}

最佳答案

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

关于c++ - netbeans 不显示 C++ 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33111471/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com