隐藏 winmain() 函数

发布于 2024-12-23 07:41:24 字数 37 浏览 3 评论 0原文

有什么方法可以隐藏类中的 WinMain() 函数吗?谢谢。

is there any way to hide the WinMain() function inside a class? Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小巷里的女流氓 2024-12-30 07:41:24

不,没有。更好的问题是“你为什么想要”?在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文