1

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. 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. How can I have multiple .cpp files in a workspace and run different ones? 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. My workspace setup currently looks like this: https://i.sstatic.net/NOVNM.png

1
  • 1
    In c++ you'll need a main() function to run, you can't choose an arbitrary class or function to 'run'. Commented Feb 2, 2014 at 0:52

1 Answer 1

2

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. (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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.