码:
#include <valarray>
#include <iostream>
using namespace std;
int main()
{
valarray<int> v0(2, 4);
valarray<int> v1;
v1 = v0;
cout << "v0.size: " << v0.size() << endl;
cout << "v1.size: " << v1.size() << endl;
cout << "v0[0]: " << v0[0] << endl;
cout << "v1[0]: " << v1[0] << endl;
}
Run Code Online (Sandbox Code Playgroud)
输出:
v0.size: 4
v1.size: 0
v0[0]: 2
Segmentation fault
Run Code Online (Sandbox Code Playgroud)
对于作业:
v1 = v0;
Run Code Online (Sandbox Code Playgroud)
我会认为构造函数:
valarray<T>& operator=( const valarray<T>& other );
Run Code Online (Sandbox Code Playgroud)
应该使用并根据文档,我相信v1应该调整大小,v0的内容复制到它,元素的元素.那真正发生了什么?
$ g++ --version
g++ (GCC) …Run Code Online (Sandbox Code Playgroud) 所以我有一个非常基本的函数与for循环.它在现代Chrome和Firefox浏览器上运行良好,但在特别挑剔的Firefox 38浏览器上却没有.根据文档,自Firefox 13以来一直支持此功能.
function showhide_class(cl) {
var es = document.getElementsByClassName(cl);
for(let e of es) {
e.style.display = (e.style.display == "block") ? "none" : "block";
}
}
Run Code Online (Sandbox Code Playgroud)
Firefox报告的确切错误是:
SyntaxError: missing ; after for-loop initializer
Run Code Online (Sandbox Code Playgroud)
那么,为什么要报告这个错误,你知道一个解决方法吗?非常感谢.