<tfoot id='mXsE7'></tfoot>
      1. <i id='mXsE7'><tr id='mXsE7'><dt id='mXsE7'><q id='mXsE7'><span id='mXsE7'><b id='mXsE7'><form id='mXsE7'><ins id='mXsE7'></ins><ul id='mXsE7'></ul><sub id='mXsE7'></sub></form><legend id='mXsE7'></legend><bdo id='mXsE7'><pre id='mXsE7'><center id='mXsE7'></center></pre></bdo></b><th id='mXsE7'></th></span></q></dt></tr></i><div id='mXsE7'><tfoot id='mXsE7'></tfoot><dl id='mXsE7'><fieldset id='mXsE7'></fieldset></dl></div>

        <small id='mXsE7'></small><noframes id='mXsE7'>

          <bdo id='mXsE7'></bdo><ul id='mXsE7'></ul>
        <legend id='mXsE7'><style id='mXsE7'><dir id='mXsE7'><q id='mXsE7'></q></dir></style></legend>

      2. 是否可以在不使用 main() 函数的情况下编写程序?

        时间:2023-10-17
      3. <i id='0P79C'><tr id='0P79C'><dt id='0P79C'><q id='0P79C'><span id='0P79C'><b id='0P79C'><form id='0P79C'><ins id='0P79C'></ins><ul id='0P79C'></ul><sub id='0P79C'></sub></form><legend id='0P79C'></legend><bdo id='0P79C'><pre id='0P79C'><center id='0P79C'></center></pre></bdo></b><th id='0P79C'></th></span></q></dt></tr></i><div id='0P79C'><tfoot id='0P79C'></tfoot><dl id='0P79C'><fieldset id='0P79C'></fieldset></dl></div>

              <small id='0P79C'></small><noframes id='0P79C'>

              <tfoot id='0P79C'></tfoot>
                <bdo id='0P79C'></bdo><ul id='0P79C'></ul>
                  <tbody id='0P79C'></tbody>
                • <legend id='0P79C'><style id='0P79C'><dir id='0P79C'><q id='0P79C'></q></dir></style></legend>
                  本文介绍了是否可以在不使用 main() 函数的情况下编写程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在面试中不断被问到这个问题:

                  I keep getting this question asked in interviews:

                  不使用main()函数编写程序?

                  Write a program without using main() function?

                  我的一个朋友向我展示了一些使用宏的代码,但我无法理解.

                  One of my friends showed me some code using Macros, but i could not understand it.

                  所以问题是:

                  没有main()真的可以编写和编译程序吗?

                  Is it really possible to write and compile a program without main()?

                  推荐答案

                  在标准 C++ 中需要一个 main 函数,所以这个问题对标准 C++ 没有意义.

                  Within standard C++ a main function is required, so the question does not make sense for standard C++.

                  在标准 C++ 之外,您可以例如编写 Windows 特定程序并使用 Microsoft 的自定义启动函数之一(wMain、winMain、wWinmain).在 Windows 中,您也可以将程序编写为 DLL 并使用 rundll32 来运行它.

                  Outside of standard C++ you can for example write a Windows specific program and use one of Microsoft's custom startup functions (wMain, winMain, wWinmain). In Windows you can also write the program as a DLL and use rundll32 to run it.

                  除此之外,您还可以制作自己的小型运行时库.曾几何时,这是一项常见的运动.

                  Apart from that you can make your own little runtime library. At one time that was a common sport.

                  最后,您可以聪明地反驳说,根据标准的 ODR 规则 main 未被使用",因此任何程序都符合条件.呸!尽管除非面试官有不同寻常的幽默感(如果有的话,他们也不会问这个问题),否则他们不会认为这是一个很好的答案.

                  Finally, you can get clever and retort that according to the standard's ODR rule main isn't "used", so any program qualifies. Bah! Although unless the interviewers have unusual good sense of humor (and they wouldn't have asked the question if they had) they'll not think that that's a good answer.

                  这篇关于是否可以在不使用 main() 函数的情况下编写程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何创建库? 下一篇:C/C++ 动态链接如何在不同平台上工作?

                  相关文章

                • <legend id='uEMVc'><style id='uEMVc'><dir id='uEMVc'><q id='uEMVc'></q></dir></style></legend>

                • <i id='uEMVc'><tr id='uEMVc'><dt id='uEMVc'><q id='uEMVc'><span id='uEMVc'><b id='uEMVc'><form id='uEMVc'><ins id='uEMVc'></ins><ul id='uEMVc'></ul><sub id='uEMVc'></sub></form><legend id='uEMVc'></legend><bdo id='uEMVc'><pre id='uEMVc'><center id='uEMVc'></center></pre></bdo></b><th id='uEMVc'></th></span></q></dt></tr></i><div id='uEMVc'><tfoot id='uEMVc'></tfoot><dl id='uEMVc'><fieldset id='uEMVc'></fieldset></dl></div>

                    <small id='uEMVc'></small><noframes id='uEMVc'>

                    • <bdo id='uEMVc'></bdo><ul id='uEMVc'></ul>

                      <tfoot id='uEMVc'></tfoot>