Sign in to follow this  
GamerTom

Compiler..Microsoft visual C++?

Recommended Posts

GamerTom    122
Hey, I just started to learn C++, im brand new to programming. The video tutorial I have is using Visual C++ and I tried looking for the program on amazon and everything but there are so many version that come up and I dont know which one is which and im very confused. What version of Microsoft visual am I suppose to buy to program in C++ and where do I buy it?

Share this post


Link to post
Share on other sites
rozz666    896
Visual C++ 2005 Express is free and you can download it from MS site.
You may also consider Borland TurboC++ Explorer which is also free, has a nice IDE and lots of components. Similar to Forms, but better, because it's not .NET.

Share this post


Link to post
Share on other sites
xissburg    204
MIne is Microsoft Visual Studio 2005 Professional but I think its the same thing: go to Tools > Options > Projects and Solutions > VC++ Directories, and just set up the directories for includes, libs, etc . .. hth

Share this post


Link to post
Share on other sites
windozer1    133
Under the Tools Menu, click on Options. In there then select the second selection (Projects and Solutions). Then under VC++ Directories. There is a dropdown box in the top right (executables, includes, libraries, etc). This is what they are referring to.

Hope this helps!

Cale

Share this post


Link to post
Share on other sites
GamerTom    122
Thank you Krazeike, ok well I got everything set up, and I wrote a simple hello world program to test it but its givving this error message:

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

and its pointing to the first { after main().


#include <iostream>

main()
{

std::cout << "Hello World!" << std::endl;

}

Whats the problem?

Share this post


Link to post
Share on other sites
GamerTom    122
Thanks again KrazeIke, it works now, can oyu or someone exaplain and help me understand what int is and why did it need it in the code, cause when I wrote it on other compilers it worked without the int.

Share this post


Link to post
Share on other sites
KrazeIke    256
It just means that the main function is returning an integer value. If you don't specify the return type, other compilers (that don't follow the C++ standard) may assume that the return type is an integer by default, which is what the error message you got was trying to tell you.

Share this post


Link to post
Share on other sites
kiome    229
Quote:
Original post by KeganWalsh
In Visual C++, this is how it should look:

*** Source Snippet Removed ***


Don't mislead beginners into bad habits, KrazeIke already offered a better solution.

Share this post


Link to post
Share on other sites
Glak    315
Quote:
Original post by kiome
Don't mislead beginners into bad habits, KrazeIke already offered a better solution.


Using the names in the std namespace is the bad habit that needs to be avoided. The std namespace exists to allow backwards compatability for legacy code; not to be a proper namespace. I think that not using namespace std is the bad habit.

Share this post


Link to post
Share on other sites
RDragon1    1205
Quote:
Original post by Glak
Quote:
Original post by kiome
Don't mislead beginners into bad habits, KrazeIke already offered a better solution.


Using the names in the std namespace is the bad habit that needs to be avoided. The std namespace exists to allow backwards compatability for legacy code; not to be a proper namespace. I think that not using namespace std is the bad habit.


What on earth are you talking about? The C++ standard library exists within the std namespace. Not sure how that has anything to do with backward compatibility...

Share this post


Link to post
Share on other sites
kiome    229
Quote:
Original post by Glak
Using the names in the std namespace is the bad habit that needs to be avoided. The std namespace exists to allow backwards compatability for legacy code; not to be a proper namespace. I think that not using namespace std is the bad habit.

Unfolding a whole namespace defeats the purpose of a namespace which is to prevent names clash.
It can save you some typing, but that's not something a programmer should strive for, if it comes at a cost of losing unambiguousness.

In this example it was not really something to worry about, though since it was directed at a beginner, who will learn from every example given, I think one should be more careful about such things - especially when a perfectly fine example was already given.


Share this post


Link to post
Share on other sites
jbadams    25675
Quote:
Original post by Glak
Quote:
Original post by kiome
Don't mislead beginners into bad habits, KrazeIke already offered a better solution.
Using the names in the std namespace is the bad habit that needs to be avoided. The std namespace exists to allow backwards compatability for legacy code; not to be a proper namespace. I think that not using namespace std is the bad habit.
Nope. The std namespace contains standard library functions and is something people definitely should be using if they're writing C++. The bad habit being mentioned is beginning the program with using namespace std;.

Share this post


Link to post
Share on other sites
darookie    1441
Quote:
Original post by GamerTom
Thanks again KrazeIke, it works now, can oyu or someone exaplain and help me understand what int is and why did it need it in the code, cause when I wrote it on other compilers it worked without the int.

"int" is the type of the return value that the "main" function usually gives back to the OS. Other compilers might accept a missing return value because they operate in C-compatibility mode. In C, every function is assumed to return an "int" value by default. This is not the case with C++, so a more strict (e.g. compliant) compiler will not accept a missing return type for a function.
This is one of the few incompatibilities between C and C++.

Share this post


Link to post
Share on other sites
kiome    229
Quote:
Original post by Phantoms
So are we saying including
using namespace std;
is developing a bad habit for a beginner, or that it should be used?

Don't use "using namespace std;".
If you really want less typing when using common things like cout, one could declare "using std::cout;". That way you can call "cout" without the namespace and it wouldn't open the whole std namespace to your application.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this