Creating a New C++ Source File

Started by sukishan, Aug 13, 2009, 06:19 PM

previous topic - next topic
Go Down

sukishan

Creating a New C++ Source File
In your project you will want to have at least one C++ source file containing the code for your program. If you have just created a new project, that project will probably already be active. Select Project, Set Active Project to see what project is currently the active one. If it is not the one to which you want to add your C++ source file, click on the correct one.

Once you are sure that you have the correct project active, select File, New. Click on the Files tab and click on C++ Source File. Then fill in the desired file name. The .cpp extension will be added automatically; there is no need to type that.

The project name and location should be correct, but glance at them to be sure. The Add to Project box should be checked and the correct project name should be shown below it. See this picture of these choices to have a better idea of what this looks like. Finally, click on OK.

You should then be in the editor, editing a blank .cpp document with the correct name. Type in your desired code. Select File, Save to save your file. You can also copy in code from another file by selecting Insert, File as Text. It is also possible to add code to a new file by using Cut, Copy, and Paste (found under Edit) to bring in code from another file.

Sometimes you will want to use more than one C++ source file. It is typical to place the main function in one source file, other stand-alone functions in another source file, and functions belonging to a user-defined class in their own source file. All of these files that belong to the same program must be added to the same project.

Hint: Make sure that all of your project's .cpp and .h files (and any data files as well) are all located under your project directory. You can use My Computer to check on the locations of these files. Many students run into problems with their projects because they have several versions of their files in various directories and don't know which ones are being used by their project.
A good beginning makes a good ending

Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:
Verification:
Please leave this box empty:

Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

shortcuts: alt+s submit/post or alt+p preview
IT Acumens Web Designing Chennai | GinGly :: Build your Personal Website | CineBuzz :: Cinema News | My Kids Diary :: Kids Memories Writing :: Book Website @ 349 Rs monthly
Copyright 2005 - 2020 :: IT Acumens :: All Rights Reserved. :: Sitemap
ITAcumens Discussion Forum with 2 lakhs post running for 15 years - Powered by IT Acumens Dedicated Server