我是C++的新手,但實際上我正在學習實驗部分,但在試驗時遇到了cout函數的問題。編譯時程序失敗。我想知道你們是否可以幫助我:這是我寫的來源。C++源代碼幫助,cout函數幫助
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
signed short int a;
signed short int b;
signed short int c;
a = 25;
b = 8;
c = 12;
cout << a << endl;
cout << b << endl;
cout << c << endl;
cout << "What is the sum of a + b - c? The answer is: ";
cout << a + b - c;
cout << endl;
cout << "Why is this?" << endl;
cout << "This is because: ";
cout << "a + b equals: " << a + b << endl;
cout << "and that minus " c << " is" << a + b - c << endl;
cout << "If that makes sense, then press enter to end the program.";
cin.get();
return 0;
}
我也想知道什麼是有符號和無符號的意思,我認爲它是依賴於編譯器?我正在使用Visual C++ 2008速成版。
感謝任何能指出我的錯誤並幫助我的人!
您可能希望添加所看到的確切錯誤消息,並指出它所指示的行。 (並非我們都是編譯器。) – sbi 2010-10-29 20:15:49
通常'signed'被省略,因爲這是正常情況,只是假設。它與'auto'類似,而且很少使用,所以下一個C++標準使它完全不同。 – 2010-10-29 20:30:28