引用临时变量的静态引用(static reference referring to temporary variable)
#include <iostream> int getID ( int k ) { static int& r = k; return r++; } int main() { int a = getID ( 10 ); int b = getID ( 10 ); std::cout << "a = " << a << ", b = " << b << std::endl; return 0; }
我不明白为什么要编译这些代码。
- 一个静态引用如何引用一个局部变量k,它将在函数调用结束时消失)。
- 在第二次调用时,我们用新变量重新初始化静态引用。 请解释一下这里发生了什么,静态REFERENCE是如何被“重新定义”的(我想我不理解对方法内部静态变量的引用的含义)。
#include <iostream> int getID ( int k ) { static int& r = k; return r++; } int main() { int a = getID ( 10 ); int b = getID ( 10 ); std::cout << "a = " << a << ", b = " << b << std::endl; return 0; }
I don't understand why this code compiles.
- How is it possible for a static reference to refer to a local variable k, which will disappear in the end of the function call).
- On the second call we reinitialize the static reference with a new variable. Please explain what happens here, how come static REFERENCE can be "redefined" (i guess that i don't understand the meaning of a reference to a static variable inside a method).
原文:https://stackoverflow.com/questions/32592616
更新时间:2023-11-22 08:11
最满意答案
.ngx-datatable.bootstrap:not(.cell-selection) .datatable-body-row:hover, .ngx- datatable.material:not(.cell-selection) .datatable-body-row:hover .datatable- row-group { background: red; }
这工作。
.ngx-datatable.bootstrap:not(.cell-selection) .datatable-body-row:hover, .ngx-datatable.material:not(.cell-selection) .datatable-body-row:hover .datatable-row-group { background: red; }
This works.
相关问答
更多-
首先关闭ngx-datatable了 checkboxable:布尔值 指示列是否应显示用于选择的复选框组件。 仅在选择模式为复选框时适用。 所以你可以告诉它你的列应该是复选框。 其次,如果您确实需要一个带有conponent的自定义模板,则需要创建一个有效的组件,然后可以将其包含在要在单元格中使用的模板中:
ngx-datatable - 如何在运行时为列定义“单元类”(ngx-datatable - how to define 'cell class' for columns at runtime)[2022-02-07]
我建议查看一些样式标题和列单元格的源代码以及如何创建列模板,例如: https://github.com/swimlane/ngx-datatable/blob/master/demo/basic/css.component.ts和https://github.com/swimlane/ngx-datatable/blob/master/demo/basic/行detail.component.ts 您可以通过在列模板标记内添加[headerClass] =“insertYourCssClassName”来 ...它不起作用,因为你正在移动触发移动的元素。 您需要将.video包装在另一个div中(称为.video-wrapper )。 然后你可以使用.video-wrapper:hover .video来移动内部元素。 此外,它之前没有用,因为你忘记了x,y值之间的逗号。 .cell { height: 20vw; border: 0.5vh solid #5776b9; width: 35vw; } .fit { height: inherit; width: inherit ...它应该工作正常: http : //jsfiddle.net/2JW32/ CSS fieldset:hover a { text-decoration: none; color: red; } HTML 您可能想要检查 ....ngx-datatable.bootstrap:not(.cell-selection) .datatable-body-row:hover, .ngx- datatable.material:not(.cell-selection) .datatable-body-row:hover .datatable- row-group { background: red; } 这工作。 .ngx-datatable.bootstrap:not(.cell-selection) .datatable-b ...可能您遇到了有关View Encapsulation的问题。 ngx-datatable在它的样式上使用ViewEncapsulation.None 。 您可以将.my-custom-cell样式定义添加到./src/styles.(s)css,也可以将组件的封装设置为None 。 如果您还不知道角度指南,可以查看视图封装的详细信息。 编辑 ( 汤姆评论的回应 ) 我也不想要这样的解决方案,但遗憾的是这似乎就是这样...我已经准备了一个演示应用程序 ,它显示了我想说的内容。 .my-custom-cell分 ...简单的解决方案 - 在鼠标悬停时添加另一个类,您可以在其中定义新颜色,并在mouseout上删除它 simple solution - on mouseover add another class where you could define new color, and on mouseout remove it保持默认组件封装并使用ng-deep :host ::ng-deep .datatable-body-cell { padding: 0 !important; } https://angular.io/guide/component-styles#deprecated-deep--and-ng-deep Keep default component encapsulation and use ng-deep :host ::ng-deep .datatable-body-cell { paddi ...对于行单元格,您可以使用此css修改它们: .datatable-body-cell-label { pointer-events: none; } 对于标题单元格来说更棘手,因为它们是可点击的以支持排序。 需要像jQuery这样的东西。 喜欢这个: $('.datatable-header-cell[title]').on('mouseenter', function(e){ e.preventDefault(); }); 顺便说一下,这些“默认的白色工具提示”是浏览器自己处理的tit ...SVG CSS Hover Styling(SVG CSS Hover Styling)[2022-06-30]
试试这个svg代码: body { background-color: gray; } svg { height: 50vh; fill: white; } .html5:hover .body, .html5 .right-fill { fill: #FFF; } .html5 .left-5, .html5 .right-5 { fill: grey; } .html5:hover .body { fill: #E34F26; } . ...相关文章
更多- js怎么在引号里面引用变量
- 各们帮忙看一下,为什么spring引用不到jdbcTemplate?
- 请教怎样根据对象的引用得到包含它的对象的引用呢?
- 微信API 引用
- java 中静态变量的问题
- Java静态变量的序列化
- Tomcat 找不到引用项目类的问题
- jsp中使用JavaBean出现“引用类不可用”
- JavaFx Main中怎么绑定Java类中的一个static变量呢?
- 用扁平化的界面设计吸引用户
最新问答
更多- 获取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的基本操作命令。。。