c ++ 11:枚举成员初始化

时间:2017-07-07 13:27:17

标签: c++11 default-constructor enum-class

我有一个如下定义的类

struct X {
    X() : data() {}

    int data;

    enum class Zzz : int { zero, one, two };
    Zzz  zzz;
};
...
X xval;

xval.zzz的值是什么 - 未定义或X :: Zzz.zero?我知道对于常规枚举它将是未定义的,我想知道键入的枚举是否表现不同。

1 个答案:

答案 0 :(得分:2)

它没有被初始化。

由于支持类型是// Create a "close" button and append it to each list item var myNodelist = document.getElementsByTagName("LI"); var i; for (i = 0; i < myNodelist.length; i++) { var span = document.createElement("SPAN"); var txt = document.createTextNode("\u00D7"); span.className = "close"; span.appendChild(txt); myNodelist[i].appendChild(span); } // Click on a close button to hide the current list item var close = document.getElementsByClassName("close"); var i; for (i = 0; i < close.length; i++) { close[i].onclick = function() { var div = this.parentElement; div.style.display = "none"; } } function falseElement(newfe) { var li = document.createElement("li"); var inputValue = newfe; //document.getElementById("myInput").value; var t = document.createTextNode(inputValue); li.appendChild(t); document.getElementById("myUL").appendChild(li); var span = document.createElement("SPAN"); var txt = document.createTextNode("\u00D7"); span.className = "close"; span.appendChild(txt); li.appendChild(span); for (i = 0; i < close.length; i++) { close[i].onclick = function() { //anonymous function is the name of this type of function https://www.w3schools.com/js/js_function_definition.asp secondelement(newfe); var div = this.parentElement; div.style.display = "none"; } } } function secondelement(newe) { var li = document.createElement("li"); var inputValue = newe; //document.getElementById("myInput").value; var t = document.createTextNode(inputValue); li.appendChild(t); document.getElementById("expended").appendChild(li); var span = document.createElement("SPAN"); var txt = document.createTextNode("\u00D7"); span.className = "close"; span.appendChild(txt); li.appendChild(span); for (i = 0; i < close.length; i++) { close[i].onclick = function() { falseElement(newe); var div = this.parentElement; div.style.display = "none"; } } } falseElement("first"); falseElement("second"); secondelement("third"); secondelement("forth");并且可以包含陷阱表示,因此在初始化之前读取<!DOCTYPE html> <html> <head></head> <body> <ul id="myUL"> </ul> <p id="divider"><br><br></p> <ul id="expended"> </ul> </body> </html> undefined 。 (出于兴趣,如果支持类型是intxval.zzzchar,那么行为将只是实现定义。)