我可以创建一个包含多个类型声明的for循环吗?(Can I create a for loop containing multiple type declarations?)

编程入门 行业动态 更新时间:2024-10-26 16:31:41
我可以创建一个包含多个类型声明的for循环吗?(Can I create a for loop containing multiple type declarations?)

例如:

有什么我可以做的,这可能会让我做到这一点:

for(TiXmlElement * pChild = elem->First(), int i=0; // note multiple type declarations pChild; pChild=pChild->NextSiblingElement(), i++) // note multiple types { //do stuff }

也许有一个boost标题?

For example:

Is there anything I can do, that might allow me to do this:

for(TiXmlElement * pChild = elem->First(), int i=0; // note multiple type declarations pChild; pChild=pChild->NextSiblingElement(), i++) // note multiple types { //do stuff }

Perhaps there is a boost header?

最满意答案

不。

如果你想限制变量的范围到循环中,只需添加另一个范围:

{ TiXmlElement * pChild = elem->First(); int i = 0; for(; pChild; pChild=pChild->NextSiblingElement(), i++) { //do stuff } }

Nope.

If you want to limit the scope of variables to the loop just add another scope:

{ TiXmlElement * pChild = elem->First(); int i = 0; for(; pChild; pChild=pChild->NextSiblingElement(), i++) { //do stuff } }

更多推荐

本文发布于:2023-07-29 20:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1319444.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   创建一个   声明   类型   create

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!