stupid, newbie question regarding MSVC++
hello people,
i hope someone can help me out here. i''m having some trouble using MSVC++... i just wanted to practice some simple programs from the ''Sams Teach Yourself C++ in 24 Hours.'' First, I went under File, created a C++ project, went under Project --> Add to project --> New...
By doing that, I created a simple hello.cpp program, and I added another .ccp file which also uses main. all in all, it told me that ''main'' function is already being used.
All I''m trying to do is make different programs under the same project. Is that not possible to do? main can only be used once under the same project?
I know I rambled on, sorry, but I''m starting out and am slightly frustrated. also, please no flames regarding the book i''m using...
anyone who helps me out, thanks in advance!
main() looks like a function, acts like a function ... well main() IS a function
Yet, main() is a very special function. That beauty is the so-called entry point to the application.
If it is missing, the programm doesn''t know where to start.
If there is more than one main() the programm (compiler) cannot decide where to start
Yet, main() is a very special function. That beauty is the so-called entry point to the application.
If it is missing, the programm doesn''t know where to start.
If there is more than one main() the programm (compiler) cannot decide where to start
Kronos
All you need to do to make a new project is the 1st thing you said. Just load up c++ go to file select new, then when you choose the type of project and set the name, it will ask you what do you wanna start with, a Hello? a Simple Project? or an empty space.
And yes I do believe that you cant call main twice,so trying to add something to your project that uses main already would give u an error like,"main already has a body" or something to that extent. I hope that makes sense. Just try what I said above.
And yes I do believe that you cant call main twice,so trying to add something to your project that uses main already would give u an error like,"main already has a body" or something to that extent. I hope that makes sense. Just try what I said above.
you can use differents projects within the same workspace,or use the CL command line without the IDE :D.
first, thanks all for replying. all the little programs have a main() function, so i basically cannot put them under the same project. is that statement correct then?
Yes, but it''s not terribly difficult to add new projects (and thus new entry points) to your current workspace.
[size=2]
You could:
Linkers don''t much like having *any* two functions with the exact same name and appearance (unless you''re overloading, but that''s a whole new ball game), let alone the main() function.
Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
- Remove the file that you''re not using from the project.
- Create a new project in the same workspace, and have one file in each. They''ll both build to seperate names and .exe files that way.
- Mark the other files as ''exclude from build.'' Go to the Project Settings dialog, and use the treeview on the left to find the file you want to exclude. Click on it, and tick ''exclude from build'' on the right hand side. The icon should change to indicate that you''re not using it.
- Comment out the file.
Linkers don''t much like having *any* two functions with the exact same name and appearance (unless you''re overloading, but that''s a whole new ball game), let alone the main() function.
Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement