Simple Answer for Simple QuestionHi guys-<br/> <br/> I know this is going to be very simple, so I apologize if you feel I've wasted your time.  I'm transitioning from NetBeans for Java to Visual C++.  In NetBeans, I used to keep a project that would just kind of be my testing ground where I would store random code I was working on, or labs for classes, etc.  I'm trying to figure out which project type will let me do the same in Visual C++.  I created an empty Visual C++ solution, added an empty project, and added about 3 source files.  Since they aren't all related, they all have a main function, and because of that, I can't build.  I just want to run one cpp file at a time, but I can't figure out how to to do it without building everything, which gives me the &quot;more than one main declared&quot; error.  I can't believe I couldn't find an answer to this anywhere else, but maybe no one else does this? I find that hard to believe, but anyways, can anyone point me in the right direction?© 2009 Microsoft Corporation. All rights reserved.Thu, 09 Jul 2009 06:05:14 Zf7a864a7-c449-4587-b962-9a21b1a313d9http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/f7a864a7-c449-4587-b962-9a21b1a313d9#f7a864a7-c449-4587-b962-9a21b1a313d9http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/f7a864a7-c449-4587-b962-9a21b1a313d9#f7a864a7-c449-4587-b962-9a21b1a313d9cmbrooks08http://social.msdn.microsoft.com/Profile/en-US/?user=cmbrooks08Simple Answer for Simple QuestionHi guys-<br/> <br/> I know this is going to be very simple, so I apologize if you feel I've wasted your time.  I'm transitioning from NetBeans for Java to Visual C++.  In NetBeans, I used to keep a project that would just kind of be my testing ground where I would store random code I was working on, or labs for classes, etc.  I'm trying to figure out which project type will let me do the same in Visual C++.  I created an empty Visual C++ solution, added an empty project, and added about 3 source files.  Since they aren't all related, they all have a main function, and because of that, I can't build.  I just want to run one cpp file at a time, but I can't figure out how to to do it without building everything, which gives me the &quot;more than one main declared&quot; error.  I can't believe I couldn't find an answer to this anywhere else, but maybe no one else does this? I find that hard to believe, but anyways, can anyone point me in the right direction?Thu, 02 Jul 2009 18:47:47 Z2009-07-02T18:47:47Zhttp://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/f7a864a7-c449-4587-b962-9a21b1a313d9#df33e64a-25b6-47cf-b7f8-3f40e266dd9ehttp://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/f7a864a7-c449-4587-b962-9a21b1a313d9#df33e64a-25b6-47cf-b7f8-3f40e266dd9eNishant Sivakumarhttp://social.msdn.microsoft.com/Profile/en-US/?user=Nishant%20SivakumarSimple Answer for Simple Question<p>Have a single main() from which you then call the test functions.  So you have main.cpp with the main() function, foo1.cpp with the Foo1() function, and foo2.cpp with the Foo2 class. Now to test foo1, you just call Foo1() from main(), and to test foo2, instantiate Foo2 in main and invoke methods on it. Repeat similarly for other classes/functions.</p><hr class="sig"><a href="http://blog.voidnish.com">http://blog.voidnish.com</a>Thu, 02 Jul 2009 18:54:38 Z2009-07-02T18:54:38Zhttp://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/f7a864a7-c449-4587-b962-9a21b1a313d9#6712570e-4b52-4ff3-90d5-e3f57a558916http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/f7a864a7-c449-4587-b962-9a21b1a313d9#6712570e-4b52-4ff3-90d5-e3f57a558916cmbrooks08http://social.msdn.microsoft.com/Profile/en-US/?user=cmbrooks08Simple Answer for Simple QuestionThere's no way to just have multiple .cpp files and right click and run (or something of the sort)? I don't want to have to build the whole project, I just want to compile the individual file and run.<br/>Thu, 02 Jul 2009 18:58:23 Z2009-07-02T18:58:23Zhttp://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/f7a864a7-c449-4587-b962-9a21b1a313d9#237e123e-4bdd-4304-8cdf-fa0c3bf878e2http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/f7a864a7-c449-4587-b962-9a21b1a313d9#237e123e-4bdd-4304-8cdf-fa0c3bf878e2Nishant Sivakumarhttp://social.msdn.microsoft.com/Profile/en-US/?user=Nishant%20SivakumarSimple Answer for Simple QuestionAs far as I know, VS needs a project to build and run - it cannot handle standalone cpp files.<hr class="sig"><a href="http://blog.voidnish.com">http://blog.voidnish.com</a>Thu, 02 Jul 2009 19:02:54 Z2009-07-02T19:02:54Zhttp://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/f7a864a7-c449-4587-b962-9a21b1a313d9#c7712cad-fca3-4dd7-8ed3-8d955c499fb7http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/f7a864a7-c449-4587-b962-9a21b1a313d9#c7712cad-fca3-4dd7-8ed3-8d955c499fb7Brian Muthhttp://social.msdn.microsoft.com/Profile/en-US/?user=Brian%20MuthSimple Answer for Simple Question<blockquote>There's no way to just have multiple .cpp files and right click and run (or something of the sort)? I don't want to have to build the whole project, I just want to compile the individual file and run.<br/></blockquote> <br/>Just create a separate project for each .cpp file. You can have multiple projects in the same solution, which is very convenient.<br/>Thu, 02 Jul 2009 19:40:11 Z2009-07-02T19:40:11Zhttp://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/f7a864a7-c449-4587-b962-9a21b1a313d9#fb380065-429e-40d1-b264-3f5c08eff656http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/f7a864a7-c449-4587-b962-9a21b1a313d9#fb380065-429e-40d1-b264-3f5c08eff656nobugzhttp://social.msdn.microsoft.com/Profile/en-US/?user=nobugzSimple Answer for Simple QuestionClick, then Shift + Click to select all the files.  Right-click, Properties, General, set Excluded from Build = Yes.  Whatever file you want to try, set it back to No and build.  Avoid this problem in the future by keeping your main() in a separate source file.<br/><hr class="sig">Hans Passant.Thu, 02 Jul 2009 20:02:57 Z2009-07-02T20:02:57Z