[英]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.