首页 \ 问答 \ 构造函数?(Constructor? or something else? [duplicate])

构造函数?(Constructor? or something else? [duplicate])

可能重复:
构造函数中这个奇怪的冒号成员语法是什么?

所以当我遇到这个时,我正在查看Direct X 10书中的一些样本

PeaksAndValleys::PeaksAndValleys()
: mNumRows(0), mNumCols(0), mNumVertices(0), mNumFaces(0),
  md3dDevice(0), mVB(0), mIB(0)
{
}

我明白这可能应该是一个构造函数......但我从来没有见过像这样的人? 谁能解释一下? 特别是为什么有一个单一的:声明之后?


Possible Duplicate:
What is this weird colon-member syntax in the constructor?

So I was looking through some samples in a Direct X 10 book, when I came across this

PeaksAndValleys::PeaksAndValleys()
: mNumRows(0), mNumCols(0), mNumVertices(0), mNumFaces(0),
  md3dDevice(0), mVB(0), mIB(0)
{
}

I understand this is probably supposed to be a constructor......but i've never seen one like this? can someone explain? specifically why is there a single : after it's declared?


原文:https://stackoverflow.com/questions/5938656
更新时间:2023-04-08 08:04

最满意答案

你可以使用html5属性,如下所示,使它们成为必需。

<select required>
<option value="">select an option</option>
<option value="value1">Value 1</option>
<option value="value2">Value 2</option>
</select>

在jsfiddle http://jsfiddle.net/88rXX/中查看示例


You can make them required by using html5 attribute required just like below.

<select required>
<option value="">select an option</option>
<option value="value1">Value 1</option>
<option value="value2">Value 2</option>
</select>

View Example in jsfiddle http://jsfiddle.net/88rXX/

相关问答

更多
  • 您必须在显示第一个输入字段时以及何时显示第二个字段以及如何使用if语句来控制它,或者定义一个布尔变量来决定如果显示为true以及如果显示为true if(!isset($_POST["files"])){ ?>
  • 简单回答。 您已经为textarea提供了内容,还有一些空白区域,其中包含现有HTML的布局方式。 因此提供了一个值。 确保textarea结束标记位于开始标记旁边,没有任何空格,因此中间没有空白内容。 喜欢这个:

    Which type of elements would you be in favor of for a future pattern for interactive media to follow?

  • 你可以使用html5属性,如下所示,使它们成为必需。 在jsfiddle http://jsfiddle.net/88rXX/中查看示例 You can make them required by using ...
  • 一遍又一遍地做同样的事情并期待不同的结果......可能在网络浏览器测试中发生,但在这种情况下不会发生。 在这种情况下,您使用相同的选择器一遍又一遍地重复相同的任务。 您需要遍历选择器。 这将无法使用CSS选择器,因为:nth-of-type()例如表示同一父级下的第n个元素,这可能不是您的站点的情况。 您应该使用XPath表达式来执行此操作。 CasperJS提供了一个XPath实用程序,可以更轻松地调用它们: var x = require('casper').selectXPath; casper.t ...
  • 将process属性移除到 ,以使selectOneRadio触发部分Ajax请求,该请求仅提交selectOneRadio本身。 使用以空格分隔的更新组件列表填充update属性,不包括inputText组件,因为您希望保留其值,并且仅在提交整个表单时才会评估其required状态。 最后,使用的listener属性调用服务器方法,该方法更新使得inputText组件所需的条件:
    它看起来像我正确的RTL视图。 Quartus选择将逻辑显示为一个9输入XOR门,而不是许多2输入XOR门。 两者的布尔行为是相同的。 没有ODD输出,因为ODD不是输出signal 。 It looks like the correct RTL view to me. Quartus has chosen to display the logic as one 9-input XOR gate instead of many 2-input XOR gates. The boolean behaviour ...
  • 为什么要使用Javascript来确定用户是否添加了图片? 什么是用户没有JS? 我会在PHP中检查这一点,但我不知道你正在使用什么框架。 Why would you use Javascript to determine if a user added a picture or not? What is when the user has no JS? I would check this in PHPbut I dont know what Framework you're using.
  • 客户端 为您的表单使用一些Javascript; 只需检查以确保所有三个等于空。 如果是这样,那么返回false ; 这将阻止提交表单,如果用户选择单个字段,则条件不再为true并且可以提交表单。 注意:我正在使用jquery; 但这很容易转录为Javascript Vanilla。 $('#submit').on('click', function() { // create variables var select1 = $('#select1'); var select2 = $ ...
  • 这里有一个地图http://jsfiddle.net/4vNcU/4/ $(document).on('click', '.check-select', function () { var error = $(".check").find("option:selected").map(collectErrors); for (var i = 0; i < error.length; i++) { alert(error[i]); } }); function collectErrors() { ...
  • 使用SQL你可以使用 UPDATE `product_option` SET `required` = 1 假设您没有表前缀。 如果这样做,请将`product_option`更改为`your_prefix_product_option` Using SQL you could use UPDATE `product_option` SET `required` = 1 That assumes you don't have a table prefix. If you do, change `prod ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。