简体   繁体   English

如何选择要在XCode中运行的.cpp文件?

[英]How do I choose which .cpp file to run in XCode?

I've seen some responses to things like this, but I'm still not sure what to do. 我已经看到了对这种事情的一些回应,但是我仍然不确定该怎么做。 I'm proficient in Java with Eclipse, and am starting C++ with XCode. 我精通Eclipse的Java语言,并且正在使用XCode启动C ++。 I'm using a textbook, so I'd like to organize my workspace with one .cpp file for each chapter, but when I do this and try to run one of the files, it always defaults to the first one. 我使用的是教科书,因此我想为每个章节使用一个.cpp文件来组织我的工作区,但是当我尝试运行其中一个文件时,它始终默认为第一个文件。 How can I have multiple .cpp files in a workspace and run different ones? 如何在工作空间中具有多个.cpp文件并运行不同的文件? This might be a fundamentally different thing than in java where you could just select the class, and if it had a main method run it from there, but any help would be appreciated. 这可能与Java根本不同,在Java中,您可以选择类,并且如果有一个主要方法可以从那里运行它,则可以提供任何帮助。 My workspace setup currently looks like this: http://i.imgur.com/HUh5lHL.png 我的工作区设置当前如下所示: http : //i.imgur.com/HUh5lHL.png

What πάντα ῥεῖ says is right. πάνταῥεῖ所说的是正确的。 To put it more bluntly, you probably don't want a single Xcode project with a different .cpp file per chapter of your text. 坦率地说,您可能不希望单个Xcode项目的文本每章都具有不同的.cpp文件。 (You can do it that way, but it involves a bunch of setup that will be confusing to you as a newbie with C++ and Xcode.) It would probably be easier if you made a separate Xcode project for each chapter. (您可以通过这种方式进行操作,但是涉及一堆设置,对于使用C ++和Xcode的新手来说,这会使您感到困惑。)如果为每个章节创建一个单独的Xcode项目,可能会更容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM