隐藏 winmain() 函数
有什么方法可以隐藏类中的 WinMain() 函数吗?谢谢。
is there any way to hide the WinMain()
function inside a class? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
有什么方法可以隐藏类中的 WinMain() 函数吗?谢谢。
is there any way to hide the WinMain()
function inside a class? Thank you.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
不,没有。更好的问题是“你为什么想要”?在 Java 或 C# 中,main 函数是静态类成员,并不是因为它更好或更干净,而是因为该语言不允许使用非成员函数。在 C++ 中,它们是被允许的,在很多情况下甚至是被鼓励的。
对于主函数(程序的入口点)来说,位于“外部”更有意义。它从一个基本上空的环境开始,然后在调用实际应用程序逻辑之前设置需要设置的任何内容。
Nope, there isn't. A better question is "why would you want to"? In Java or C#, the main function is a static class member, not because it is better or cleaner, but because the language does not allow non-member functions. In C++, they are allowed, and even encouraged in many cases.
It makes more sense for the main function, the entry point to your program, to be "outside". It starts in a basically empty environment, and then it sets up anything that needs to be set up before calling into the actual application logic.