I am using visual studios. Below is my current project folder structure.
I am actually practicing all codes in a book. So, i want to create a folder for each chapter and write each exercise in a separate .cpp file. But, i am not sure if creating folders under "source files" folder is the correct thing to do. Should i create a folder inside of Source files or outside? what's the standard way of doing it?
Just add them to separate projects. To do that, simply right-click the solution, select Add -> New Project... That will bring up a wizard to make a new project in your solution. Then, you can have another main inside that project.
Related
I am currently creating a small project over the summer using c++ and visual studio 2010. I wanted to organize the individual .cpp and .h files into their own folders in the project directory. While I use filters in the actual project, I do understand that these are filters, not folders.
So my question is this. In my source, I currently have a header folder called GameStateManger.h, and a folder called Tank_Headers and Tank_CPPs. I also have Tank.h, and Tank.cpp, in their respective folders. My problem is that in GameStateManager, I have this #include "Tank_Headers\Tank.h", however, in my Tank.h, when I type #include... nothing shows up. I cannot find anything. However, if I make a new header, and put it in just source, I can search for those folders. I want to be able to organize my .h files and my .cpp files into individual folders in my source folder, so it is much more organized, considering the project might get very big very soon.
Thank you!
try to use #include "Tank.h"
That should work as long as you add the file to your project first. Drag it from explorer into whatever filter you want it organized it into.
Sorry I forgot to add:
You need to add the subfolder to your project. Go to the project properties, look under C/C++ and add it to Additional Include Folders.
I have an existing Netbeans C++ project I want to change to a Netbeans Qt- Application. Is there an easy way to do it or do I have to reimport all my classes?
I do not know of any way to change a netbeans project after it is created. I would just make a new Qt application project. Then you can right click on the project name and choose "add existing items from folders...". That will allow you to import a whole folder of code files at one time. I would copy all the code out of the old project folder and into the new project folder before adding them, so the project code is all at the same place. Hope this helps.
I am normally a C# guy but trying to get into c++.
I made myself a new openframeworks project by copying and pasting one of the example projects and then renaming everything to my project name. (If there is an easier way, I would love to hear it)
This project has the .cpp and .h files in a sub folder called "src" which are in turn organized into virtual folders (filters???) in visual studio.
How can I add a class to this project from within visual studio?
If I right click on the src filter in the solution explorer and hit add class. It creates the class files at the root of the project not in the src folder. I mean it does this both in the solution explorer and where it physically places the files. This is a problem because I can't include my class files in the rest of my app, presumably because they aren't in the same folder
What is the proper way to add a class file?
When you right click on the filter (could be the "src" or a new one) and hit 'Add class', after hitting 'Add' in the first screen, in the next one you will find a [...] button besides each text input field for the .h .cpp files: with that button you can chose the folder where your files are going to be saved ('src' or any other).
It isn't a good solution but the only way I have found to do this is to add the class in visual studio, which places it in the root. Exclude the files from the project. Move the files to the src folder using Windows Explorer. Include them in the project by showing all files and then right clicking to include in project. At this point I would expect the files to be listed in the project but don't appear until I reload the project. Once the project is reloaded I then drag and drop the files into the src folder/filter
I want to modify an existing project but put all the source and header files etc. into a new directory to keep them separate. When I use the "create new project from existing code" option, the solution files seem to point back to my original .cpp file which I don't want.
Q - what the best way to do this?
The Visual Studio projects are simple XML files that can be edited. Just bulk replacing the paths in your favorite text editor is probably the easiest way to go (I do that all the time).
create a new project, without opening the existing one.
then copy all the header and the cpp files from the older folder to the new project folder.
'add existing item' will only point to the original file only.
Im sure there is a very simple solution for this.
I have a bunch of .cpp / .h files from a project, say in directory ~/files
On the other hand, I want to create a c++ project using eclipse to work on those files, so I put my workspace on ~/wherever. Then I create a c++ project: ~/wherever/project, and include the source files (located in /~files).
The problem i'm having is that files are now duplicated in ~/wherever/project, and I would like to avoid that, specially so I know which copy of the file to commit.
Is this possible? Im sure it is, but cant get it.
Thanks in advance.
You could try:
creating the project directly above the ~/files (which is not very clean, given the location of the sources in your home dir)
using a linked folder
importing existing sources in your project: details all the options (when your sources are also managed by a VCS like CVS, or when your sources are not managed)
Create a file or folder in your project as per normal (choose File->New->Folder), give it a name, and click on the Advanced button. This reveals a file-choose field where you can browse for the resource you want to "virtually" include in the project. Click Okay and the file/folder you named is now linked outside of the project.