volatile const int意思是C?(volatile const int meaning in C?)
我正在读一本关于C的书 。它提到了一个对我来说没有意义的概念。 我所知道的是,编译器有时通过删除感觉不会影响表达式的变量来优化代码。 因此,如果我们将volatile指定给变量,则不会从任何表达式中删除此变量。
所以这本书介绍了这样的东西:
volatile const int a = 1;
解释只有几行,对我来说都没有意义。 有人可以解释为什么需要这样的变量?
PS:我理解volatile的概念,我不理解的是volatile const的概念。
I am reading a book on C. It mentions a concept which does not make sense to me. What I know is that the compiler sometimes optimises code by removing variables which it feels would not affect an expression. So if we specify volatile to a variable, it does not remove this variable from any expression.
So the book introduces something like this:
volatile const int a = 1;
The explaination is only a couple of lines, none of which makes sense to me. Can somebody please explain why would be there a need of such a variable?
PS: I understand the concept of volatile, what I dont understand is the concept of volatile const.
原文:https://stackoverflow.com/questions/20353499
最满意答案
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/> <div class="well"> <p> This is a well content </p> </div> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script> $(".well").mouseenter( function(){ $(this).css('background-color','red'); }); $(".well").mouseleave( function(){ $(this).css('background-color','#f5f5f5'); }); </script>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/> <div class="well"> <p> This is a well content </p> </div> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script> $(".well").mouseenter( function(){ $(this).css('background-color','red'); }); $(".well").mouseleave( function(){ $(this).css('background-color','#f5f5f5'); }); </script>
相关问答
更多-
按ID选择div元素比按类选择div元素更具体,因此正在覆盖.e:hover样式。 只需将您的代码更改为 #menu-button { background-color: azure; color: black; height: 3.5vw; width: 23%; margin-left: 2%; color: black; margin-top: 2%; float: left; } #menu-button:hover { background-color: bl ...
-
停止Bootstrap3按钮文本以在鼠标悬停时变为下划线(Stop Bootstrap3 button text to turn underline on mouseover)[2022-07-19]
下划线由文本修饰CSS属性控制,而不是font-style属性。 此外,下划线不会应用于按钮标签本身,而是应用于按钮内的锚标签。 看这个演示: a { text-decoration: none; } Underlines are controlled by the text-decoration ... -
将一个类添加到主容器( cls: 'test' )并将其添加到样式表: .test .x-accordion-hd-over { background-color: yellow; } 悬停时应改变标题颜色。 这是一个小提琴: https : //fiddle.sencha.com/#fiddle/c8b Add a class to your main container (cls: 'test') and add this to your stylesheet: .test .x-accord ...
-
那么这也可以用css来完成 a.home-block-button:hover .gridInner{ background-color:#302f52; } a.home-block-button:hover .gridInner h2{ color:#fff; } 在你的情况下,如果你想使用js,那么只需编写这样的代码 $( "a.home-block-button" ).hover( function() { $(this).find('.gridInner').css({'ba ...
-
没有html / css没有内置这个选项,但是因为你在javascript中访问/设置颜色,你可能需要添加你自己的函数来处理这个问题。 以下是您的一个例子: