如果别的 [英] if else

查看:84
本文介绍了如果别的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在c ++中,不存在if语句,例如在Visual Basic中,

是吗?


// VB类比:

如果(cond。)

声明;

否则如果(cond。)

声明;

else

声明;


在c ++中,只有嵌套的if-else-constructs是可能的,对吗?

所以,上面的例子在c ++中有以下逻辑:


if(cond。)

语句;

else

if(cond。)

声明;

else

声明;


与第一个不同。我是否正确掌握了这一点?


谢谢

In c++ there does not exist an if-statement as for example in Visual Basic,
does it?

//VB-analogy:
if (cond.)
statement;
else if (cond.)
statement;
else
statement;

In c++ only nested if-else-constructs are possible, right?
So, the above example would have the following logic in c++:

if (cond.)
statement;
else
if (cond.)
statement;
else
statement;

which is different from the first. Have I grasped this correctly?

Thanks

推荐答案



" Roman T?ngi < RO ********** @ bluewin.ch> schrieb im Newsbeitrag

news:42 ********** @ news.bluewin.ch ...

"Roman T?ngi" <ro**********@bluewin.ch> schrieb im Newsbeitrag
news:42**********@news.bluewin.ch...
在c ++中没有if-例如在Visual
Basic中的声明,是吗?

// VB类比:
if(cond。)
声明;
如果(cond。)
声明;

声明;

在c ++中,只有嵌套的if-else-constructs是可能的,对吧?
所以,以上示例在c ++中具有以下逻辑:

if(cond。)
语句;

if(cond。)
语句;

声明;

与第一个不同。我是否正确掌握了这个?
In c++ there does not exist an if-statement as for example in Visual
Basic, does it?

//VB-analogy:
if (cond.)
statement;
else if (cond.)
statement;
else
statement;

In c++ only nested if-else-constructs are possible, right?
So, the above example would have the following logic in c++:

if (cond.)
statement;
else
if (cond.)
statement;
else
statement;

which is different from the first. Have I grasped this correctly?




上面的VB是:

if(cond)

statement;

否则if(cond2)

statement2;

else

statement3;


您的C ++示例想要做的是:


if(cond)

声明;

else

{

if(cond2)

statement2;

else

statement3;


}


HTH,

Gernot



The VB above is:
if(cond)
statement;
else if(cond2)
statement2;
else
statement3;

what your C++ sample wants to do is:

if(cond)
statement;
else
{
if(cond2)
statement2;
else
statement3;

}

HTH,
Gernot


我是什么意思是:if if语句作为if的组成部分在c ++中不存在
。只有嵌套才能模拟这个。
What I mean: an if else statement as constituent part of if does not
exist in c++. Only nesting is possible to simulate this.


* Roman T?ngi:
* Roman T?ngi:

在c ++中,不存在if-例如在Visual Basic中的声明,
是吗?


存在。


// VB类比:
if(cond。)
声明;
如果(cond。)
声明;
其他
声明;


你的意思是VB


如果COND那么

声明

elsif COND

声明

其他

声明

endif


在c ++中,只有嵌套的if-else结构是可能的,对吧?


正确。


所以,上面的例子在c ++中会有以下逻辑:

if(cond 。)
声明;
否则
if(cond。)
声明;

声明;


是的,除非你不应该按照你的方式缩进。


见第8节使用if-否则从n个动作中选择第1.4章

我尝试过正确的C ++教程

< url:http://home.no.net/dubjai/win32cpptut/html/w32cpptut_01.html> 。


与第一个不同。


不是真的。


VB" elsif"关键词只是语法上的含糖。


我是否正确掌握了这个?

In c++ there does not exist an if-statement as for example in Visual Basic,
does it?
It exists.

//VB-analogy:
if (cond.)
statement;
else if (cond.)
statement;
else
statement;
What you mean is probably VB

if COND then
statement
elsif COND
statement
else
statement
endif

In c++ only nested if-else-constructs are possible, right?
Right.

So, the above example would have the following logic in c++:

if (cond.)
statement;
else
if (cond.)
statement;
else
statement;
Yes, except you shouldn''t indent this the way you''ve done.

See section 8 "Use if-else to select from n actions" of chapter 1.4
of my attempted correct C++ tutorial at
<url: http://home.no.net/dubjai/win32cpptut/html/w32cpptut_01.html>.

which is different from the first.
Not really.

The VB "elsif" keyword is just syntactic sugaring.

Have I grasped this correctly?




差不多。


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么这么糟糕?

A:热门发布。

问:usenet和电子邮件中最烦人的是什么?



Almost.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


这篇关于如果别的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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