嗯,编译没有任何错误可以吗? (vc71) [英] hm, is this ok to compile without any error? (vc71)
本文介绍了嗯,编译没有任何错误可以吗? (vc71)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
X级
{
public:
X(){_ tprintf(_T(" Hey!\ n"))) ;}
};
int _tmain(int argc,_TCHAR * argv [])
{
X(qwerty);
返回0;
}
输出:嘿!
解决方案
是的,它可以用VC7.1编译好,而且它也适用于在线
Comeau编译器。
您想指出什么?
Dave
-
MVP VC ++常见问题: http://www.mvps.org/vcfaq
>是的,它可以用VC7.1编译好,并且它也可以在线Comeau编译器。
您想指出什么?
奇怪的是,类X在其构造函数中没有参数,我可以
仍然传递一个:qwerty,这是无处定义的。
还有一个关于为什么我问它是否正常的说明。当我意外地将我的一个
函数重命名为已经存在的类名时,这个来自
编译器的行为让我感到困惑。然后它没有编译
课程。但是当我重命名这个函数并且返回它们之前的那些它们时,我忘了在一个地方执行它,并且调用了该类的
默认构造函数而不是我的旧功能。我花了几分钟才知道发生了什么事情:)
class X
{
public:
X() {_tprintf(_T("Hey!\n"));}
};
int _tmain(int argc, _TCHAR* argv[])
{
X(qwerty);
return 0;
}
output: Hey!
解决方案
Yes, it compiles OK with VC7.1, and it''s also ok with the online
Comeau compiler.
What were you trying to point out?
Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
> Yes, it compiles OK with VC7.1, and it''s also ok with the onlineComeau compiler.
What were you trying to point out?
Just strange that class X takes no parameter in its constructor and I can
still pass one: "qwerty", which was defined nowhere.
One more note about why I asked if it was ok. This behavior from the
compiler confused me yesterday when I accidentally renamed one of my
functions to an already existing class name. Then it didn''t compile of
course. But when I was renaming the function and the refereces back what
they were before, I forgot to do it at one place, and that called the
default constructor of the class instead of my old function. It took me a
few minutes to realize what was happening :)
这篇关于嗯,编译没有任何错误可以吗? (vc71)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文