0
我已經交流數組,它包含valarrays如下面的代碼剪斷,如何處理中AC陣列valarray中內接一個元素
#include <iostream>
#include <valarray>
#include <math.h>
using namespace std;
typedef uint uint32_t;
typedef std::valarray<uint32_t> uivector;
int main()
{
uivector a[] = { uivector(uint32_t(1),8), uivector(uint32_t(2),4), uivector(uint32_t(3),5) };
}
現在我該怎樣訪問,比方說,對第三個元素第二個valarray
(價值有2
),沒有做任何副本,並在一個單行的聲明?是否有可能超載[]
運營商實現相同?像a[1][2]
?
[Demo](http://ideone.com/WS998k) –
不,這個問題沒有。嘗試一個超出界限的索引,如[1] [20],你仍然會看到零被打印出來,並且不會顯示索引超出界限的錯誤。 – Naveen
是否有可能超載第二個[]運算符進行超出界限檢查? – Naveen