Ok I'm sure this will get closed as its probably not a real question, but before that happens, I'm really curious on something: Why is this program erroneously rejected by three C++ compilers? I'm just now taking a data structures and algorithms course, so I'm not really skilled in C++ and have only dealt with basic stuff, so I have no idea what the above joke is all about. Its
好吧,我相信这会被封闭,因为它可能不是一个真正的问题,但在这之前,我真的很好奇:为什么这个程序被三个C ++编译器错误地拒绝了? 我现在刚刚学习了一个数据结构和算法课程,所以我对C ++并不熟练,只处理基本的东西,所以我不知道上面的笑话是什么。 它得到了如此多的选票,人们说他们不能停止笑,但我根本不明白。 有人可以解释这个吗? 他不是将程序作为文本输入到编译器,而是使用包含手写代码图片的位图(PNG,如
I've seen std::string used in a .c file. std is a c++ namespace and namespaces were introduced in c++. Why is that so? Shouldn't it throw an error? Yes, it will cause numerous compiler errors if it's compiled as C code. If it's being compiled as C++ instead, then it will compile fine. For example, GCC has the -x option to select the language to compile as, so you can compil
我在.c文件中看到了std::string 。 std是一个c ++命名空间,命名空间是在c ++中引入的。 为什么? 它不应该抛出一个错误? 是的,如果它编译为C代码,会导致大量编译器错误。 如果它被编译为C ++,那么它会很好地编译。 例如,GCC具有-x选项来选择要编译的语言,因此如果您想使用-x c++则可以将.c编译为C -x c++ 。 同样,Microsoft Visual C ++编译器有选项/Tc和/Tp分别选择C和C ++的源语言。 我建议您修复您的构建系
I am using Orwell Dev C++ 5.8.3 IDE. It uses g++ 4.8.1 compiler. When I am saving my C++ program files it shows to several file extensions for saving my C++ program files like .cpp, .cc, .cxx, .c++, .cp . Does it matter which extension I choose? Are these extensions compiler/IDE specific or platform specific? I am using windows 7 operating system. Are these extensions also available and
我正在使用Orwell Dev C ++ 5.8.3 IDE。 它使用g ++ 4.8.1编译器。 当我保存我的C ++程序文件时,它会显示几个文件扩展名,用于保存我的C ++程序文件,如.cpp, .cc, .cxx, .c++, .cp 。 我选择哪个分机有什么关系? 这些扩展是编译器/ IDE特定的还是平台特定的? 我正在使用Windows 7操作系统。 这些扩展是否可用和/或是否可用于其他操作系统,如Unix或Linux? 为什么有这么多的扩展提供? 是什么原因? 该标准
my program wont compile because it did not found match for the operand. It accesses the map in struct Student, I am not sure if this is the exact way to access map. my program wont compile because it did not found match for the operand. It accesses the map in struct Student, I am not sure if this is the exact way to access map. #include <iostream> #include <vector> #include <i
我的程序不会编译,因为它找不到操作数的匹配。 它访问struct Student中的地图,我不确定这是否是访问地图的确切方式。 我的程序不会编译,因为它找不到操作数的匹配。 它访问struct Student中的地图,我不确定这是否是访问地图的确切方式。 #include <iostream> #include <vector> #include <iterator> #include <algorithm> #include <string> #include <map> #include <list>
Possible Duplicate: C++ source in unicode I just discovered this line of code in a project: string überwachung; I was surprised, because actually I thought you are not allowed to use umlauts like 'äöü' in C++ code other than in strings and so on, and it would result in a compiler error. But this compiles just fine with visual studio 2008. Is this a special microsoft feature, or a
可能重复: unicode中的C ++源代码 我刚刚在一个项目中发现了这一行代码: string überwachung; 我很惊讶,因为实际上我认为你不允许在C ++代码中使用类似'äöü'的变音符号而不是在字符串等等,并且会导致编译器错误。 但是,这与Visual Studio 2008编译得很好。 这是一个特殊的微软功能,还是其他编译器允许的元语言? 是否有任何潜在的问题(可移植性,系统语言设置..)? 我清楚地记得这是不允许的。 它
I have just seen this within the past few days and cannot figure out how it works. The video I talk about is here: It's the top rated answer from this Stack Overflow question: Why was this program rejected by three compilers? How is this bitmap able to show a C++ program for "Hello World"? A BMP (DIB) image is composed by a header followed by uncompressed1 color data (for 24
在过去的几天里,我刚刚看到了这一点,无法弄清楚它是如何工作的。 我讲的视频在这里: 它是这个堆栈溢出问题的最高评价答案:为什么这个程序被三个编译器拒绝? 这个位图如何能够显示“Hello World”的C ++程序? 一个BMP(DIB)图像由一个头部和一个未压缩的颜色数据组成(对于24个bpp图像,每个像素3个字节,以反向行顺序存储并且具有4个字节的行跨度)。 颜色数据的字节用于表示颜色(即,它们都不是由文件格式2“强制
I'm running Windows 7 French and I'm trying to compile this really basic program, but Visual Studio is being stubborn and refuses to comply. I also tried compiling it with both GCC 4.7 and Clang trunk on Coliru and I get more or less the same errors (output is below the code), though I think Coliru runs on an English OS so I wouldn't expect it to work anyway. What am I doing wrong?
我正在运行Windows 7法语版,并且正在尝试编译这个非常基本的程序,但Visual Studio正在固执并拒绝遵守。 我也尝试在Coliru上使用GCC 4.7和Clang trunk来编译它,并且我得到或多或少相同的错误(输出低于代码),但我认为Coliru运行在英文操作系统上,所以我不希望它仍然可以正常工作。 我究竟做错了什么? 我该如何解决它? 码 #inclure <iostream> ent principal(ent argn, ent** argm) // entier, nombre d'arg
This question already has an answer here: Why is this program erroneously rejected by three C++ compilers? 31 answers You need to enter the values of "a" and "b" before the initialization of "c". As it stands when calculating "c" both "a" and "b" are empty. Also you will have loss of precision because c is not a double. Unfort
这个问题在这里已经有了答案: 为什么这个程序被三个C ++编译器错误地拒绝了? 31个答案 在“c”的初始化之前,您需要输入“a”和“b”的值。 当计算“c”时,“a”和“b”都是空的。 你也会失去精度,因为c不是双精度。 不幸的是,你正在对两个空的未定义数字进行计算(a / 5) * b 。 考虑一下,如果你从上到下阅读你的代码(这通常是语言解释函数的方式),那么每条语句都会被解释为: Create 'a' as an integer... (Since you
The problem of using doubles as keys in maps/sets is floating point precision. Some people have suggested adding an epsilon in your compare function, but that means your keys will no longer fulfil the necessary strict weak ordering criterion. This means that you will get a different set/map depending on the order of inserting your elements. In the case where you want to aggregate/combine/mer
在映射/集合中使用双精度的问题是浮点精度。 有些人建议在你的比较函数中增加一个epsilon,但这意味着你的密钥将不再满足必要的严格弱排序标准。 这意味着您将根据插入元素的顺序获得不同的设置/地图。 如果你想基于double值聚合/合并/合并数据,并且愿意允许某个级别的rounding / epsilon(显然,你必须),下面的解决方案是一个好主意吗? 将所有双精度(我们打算用作关键点的精度)乘以精度因子(例如1e8)并舍入到最
I've always been a little confused about what's going on here: #include <stdio.h> int main() { timeval tv; tv.tv_sec = 1; for (;;) { select(0, 0, 0, 0, &tv); printf("%sn", "Hello World!"); } } Sorry if that doesn't compile, just wrote it as a quick example. Code like this won't compile under gcc unless I add the keyword struct prio
我一直对这里发生的事情有点困惑: #include <stdio.h> int main() { timeval tv; tv.tv_sec = 1; for (;;) { select(0, 0, 0, 0, &tv); printf("%sn", "Hello World!"); } } 很抱歉,如果没有编译,只是将它写成一个简单的例子。 这样的代码不会在gcc下编译,除非在使用struct timeval之前添加关键字struct 。 另一方面,g ++可以很好地处理它。 这与C和C ++如何处理结构