为什么我们使用*,〜,//,:before和:after? [英] Why we use *, ~, //, : before and :after ?

查看:73
本文介绍了为什么我们使用*,〜,//,:before和:after?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我们使用*,〜,//,:之前和之后?



我尝试过:



为什么我们在html *,〜,//,:before和:after之后使用?

解决方案

这不是我怀疑是HTML,它是C,C ++或C#。

从最后一个开始:

 x = a? b:c; 

这是的简写,如果...... else 声明:

 如果(a)
{
x = b;
}
else
{
x = c;
}

如果问号左边的条件为true,则返回冒号左边的值。如果它是假的,它会返回冒号右边的值。

这很有用 - 但可以过度使用。一般来说,如果你不确定,或者你需要嵌套它们,请使用完整的 if ... else



//表示注释:编译器会忽略该行的其余部分,因为它是人类可读的文本,旨在帮助解释为什么它喜欢它的代码:

< pre lang =c ++> x =发送( DIR C:); // 获取根文件夹内容。

右边的内容//向开发者解释发送(DIR C:)的目的是什么。



〜是按位NOT运算 - 操作数中的所有1位都设置为0,并且所有0位都设置为1。如果你使用枚举,并且想要创建一个掩码以检查两个或多个值是否一起使用,这会很有用。



*是指针运算符,我不是在这里解释! 指针 - C ++教程 [ ^ ]涵盖得很好。


Why we use *, ~, //, : before and :after ?

What I have tried:

Why we use in html *, ~, //, : before and :after ?

解决方案

This isn't HTML, it's C, C++ or C# based, I suspect.
To start with the last one:

x = a ? b : c;

This is a shorthand for an if ... else statement:

if (a)
   {
   x = b;
   }
else
   {
   x = c;
   }

If the condition to the left of the question mark is true, it returns the value to the left of the colon. if it's false, it returns the value to the right of the colon.
It's useful - but can be overused. In general, if you aren't sure, or you need to nest them, use the full if ... else instead.

// indicates a comment: the rest of the line is ignored by the compiler, as it is human readable text intended to help explain why the code it like it is:

x = Send("DIR C:");  // Get the root folder content.

The stuff to the right of the // explains to a developer what the Send("DIR C:") is intended to do.

~ is the bitwise NOT operation - all the 1 bits in the operand are set to 0, and all the 0 bits are set to one. This is helpful if you are using an enum, and want to create a mask to check if two or more values are used together.

* is a pointer operator, and I'm not explaining that here! Pointers - C++ Tutorials[^] covers it well.


这篇关于为什么我们使用*,〜,//,:before和:after?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆