how does url within function body get compiled(函数体内的 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 是如何编译的


- 近似搜索的工作原理 2021-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- C++ 协变模板 2021-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 从python回调到c++的选项 2022-11-16
- 静态初始化顺序失败 2022-01-01