函数体内的 url 是如何编译的

how does url within function body get compiled(函数体内的 url 是如何编译的)

本文介绍了函数体内的 url 是如何编译的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将一个 url 粘贴到我的代码中,忘记评论它,但看到 MSVC++ 成功编译它,我很惊讶.我的代码是这样的,

I just pasted a url to my code, and forgot to comment it, but I was surprised to see MSVC++ compiled it successfully. My code is like this,

void my_function()
{
    http://www.google.co.in/
}

这怎么会被 MSVC++ 编译?

How come this gets compiled by MSVC++?

推荐答案

其实http后面跟一个冒号被当成标签通过 C++,您可以在 goto 语句(如 goto http;)和其他语句(即 //www.google.co.in) 被视为单行注释.这就是它被编译的原因.

Actually, http followed by a colon is treated as a label by C++, which you can use in goto statements (like goto http;), and the rest (i.e //www.google.co.in) is treated as single line comment. That's why it gets compiled.

查看更多,

 void your_function()
 {

        http://www.google.co.in/

        https://www.crazy_c++.com/

        ftp://c++_is_fun.edu

        //your code here
        int i = 10 ; //atleast one line of code is needed here to get compiled!
 }

<小时>

顺便说一句,我认为您编写的示例不会被编译.url 后面应该至少有一行代码,然后才能在我的 PC 上编译.我正在使用 MSVC++ 2008.


By the way, I don't think the example you've written would get compiled. There should be at least one line of code after the url, only then it gets compiled on my PC. I'm using MSVC++ 2008.

这篇关于函数体内的 url 是如何编译的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:函数体内的 url 是如何编译的

基础教程推荐