我有一些很久以前做過的代碼(當時我使用的是visual studio 2003)。現在我正在使用gcc,一些值溢出了,我看了看發生了什麼,這讓我很驚訝。 讓我給什麼要去: 作品(輸出= 85): int b = 35000000;
unsigned long a = 30000000;
unsigned long n = (100 * a)/b;
不工作(溢): int b = 35000
#include <iostream>
#include <vector>
using namespace std;
//
// Below is what I want but not legal in current C++!
//
vector<int> operator ...(int first, int last)
{
vector<int> coll;