这就是我今天编写的内容
#include <iostream>
using namespace std;
int function1()
{
cout<<"hello from function1()"; return 0;
}
int function2()
{
cout<<"hello from function2()"; return 0;
}
int main()
{
int func_diffresult = 0;
func_diffresult = function1() - function2();
cout<<func_diffresult; /** prints 0 correctly **/
}
Run Code Online (Sandbox Code Playgroud)
输出是得到的hello from function2()hello from function1()
.我认为输出应该是hello from function1()hello from function2()
.我的编译器和我一起玩吗?
当它注意到具有未定义/未指定/实现定义的行为的语句时,编译器是否不能发出警告(如果它抛出错误会更好)?
可能会将语句标记为错误,标准应该这样说,但它至少可以警告编码器.实施这种方案有任何技术困难吗?或者它只是不可能?
我得到这个问题的原因是,在语句中,a[i] = ++i;
如果不知道代码是在尝试引用变量并在到达序列点之前在同一语句中修改它.
在创建实例之前,是否可以不指定父类?
例如这样的事情:
class SomeParentClass:
# something
class Child(unspecifiedParentClass):
# something
instance = Child(SomeParentClass)
Run Code Online (Sandbox Code Playgroud)
这显然行不通。但是有可能以某种方式做到这一点吗?
可以有python函数,其中包含未指定数量的参数,例如
myfunc(a, b, c)
myfunc(a, b, c, d, e)
Run Code Online (Sandbox Code Playgroud)
哪两个都有效?
unspecified ×4
arguments ×2
c++ ×2
function ×2
python ×2
c ×1
evaluation ×1
inheritance ×1
undefined ×1