• Steam recently changed the default privacy settings for all users. This may impact tracking. Ensure your profile has the correct settings by following the guide on our forums.

Is it me or the VS compiler sucks?

elite

Oldie moldie
I was trying to compile a simple source code I made, but it didn't with a heck load of errors.

#include <iostream>
using namespace std;

class Employee
{int Age;
public:
int GetAge();
void SetAge(int age);
}

int Employee::GetAge()
{return Age;}

void Employee::SetAge(int age)
{
Age=age;
}

main()
{Employee elite;
elite.SetAge(16);
cout<< "elite is an Employee who is " << elite.GetAge() <<" years old.";
}

Error 1 error C2628: 'Employee' followed by 'int' is illegal (did you forget a ';'?) c:\users\elite\documents\visual studio 2010\projects\sal\sal\sal.cpp 11 1 sal
Error 2 error C2556: 'Employee Employee::GetAge(void)' : overloaded function differs only by return type from 'int Employee::GetAge(void)' c:\users\elite\documents\visual studio 2010\projects\sal\sal\sal.cpp 12 1 sal
Error 3 error C2371: 'Employee::GetAge' : redefinition; different basic types c:\users\elite\documents\visual studio 2010\projects\sal\sal\sal.cpp 12 1 sal
Error 4 error C2143: syntax error : missing ';' before '}' c:\users\elite\documents\visual studio 2010\projects\sal\sal\sal.cpp 15 1 sal
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\elite\documents\visual studio 2010\projects\sal\sal\sal.cpp 18 1 sal
Error 6 error C2264: 'Employee::GetAge' : error in function definition or declaration; function not called c:\users\elite\documents\visual studio 2010\projects\sal\sal\sal.cpp 20 1 sal

Is there any specific thing I have to add to correctly compile it? I see this compiler is harder to use than any other compiler.
 

elite

Oldie moldie
How the hell did I miss that? xD I think I owe VS an apology. :p

After I placed the semi colon, an error popped out when compiling which indicated that I can't leave main() without a type. Is this true for all compilers? The book I am using states it without type.

Another thing, what's the best compiler?
 

amrcidiot

MFM Survivor
VS, at least for me, has been a pretty solid compiler.
And yeah, leaving main() without a type, such as int, will give some errors.
My C++ professor gave us a link that has some helpful knowledge in it, I'll search around later and let you know.
 

SilverSpring

New Member
It is true for standards-conforming compilers. Whichever book you are using obviously isn't teaching you Standard C.

The Standard ONLY allows for:

int main(void)

not

main()

not even

int main()

but

int main(void)

Regarding "best" compiler, it's hard to say no to a free open source compiler like GCC.

EDIT: oh I forgot, you are using C++. But AFAIK the C++ Standard should say the same thing.
 

slicer4ever

Coding random shit
yes, u NEED to return a type in any function that you make(unless it's a void function), not only is it good coding practice, it's also required in most, if not all, compilers.
 

LocutusEstBorg

Active Member
Does anyone program in C++ anymore? Aside from performance critical applications and games? I find it a NIGHTMARE compared to Java to make anything remotely complex in C++ due to the lack of libraries and the overall low level of Windows API calls. I dare not use anything other than C for a native application in Visual Studio, and C# .NET for desktop applications. C++ .NET is an extremely mangled and convoluted language requiring all kinds of intricate knowledge about the .NET data types and casting/wrapping.
 

ultimakillz

Teh Fett Mawn
from what my professors told me, its used a lot "in the industry", but many of the jobs im seeing now-a-days are requiring java, or a visual language like c#. but c++ is still widely used in the software industry.
 

angelsniper45

New Member
I dont know anything about C++, but I have done a LOT of C#. I use VS and VS only. I have tried others out there, but VS has definitely been the best for me at least. No matter how complex the program was.
 

ultimakillz

Teh Fett Mawn
thats because c# is a visual language. it would be very difficult (if not impossible, ive never actually tried) to write a c# program in a text editor and then compile it, like you can with c++. vs has lots of bells and whistles that are good for some languages, but not for others. like SilverSpring said, as far as c/c++ is concerned, you really cant beat free & go with gcc/g++.
 

ultimakillz

Teh Fett Mawn
lol, guess i should have read the article completely before using it as a reference :argh: im not sure that i agree with that completely. anyone who has programmed in c# knows that you can build and modify the program graphically, but i guess the fact that those changes are also textually represented in code means that c# is not a visual programming language by its strictest definition.

anyway, the point i was trying to make originally was that visual studio is good for languages that have graphical elements (such as c#).
 

angelsniper45

New Member
lol, guess i should have read the article completely before using it as a reference :argh: im not sure that i agree with that completely. anyone who has programmed in c# knows that you can build and modify the program graphically, but i guess the fact that those changes are also textually represented in code means that c# is not a visual programming language by its strictest definition.

anyway, the point i was trying to make originally was that visual studio is good for languages that have graphical elements (such as c#).

Um. By that they mean editing the resources, you are probably thinking of Visual Basic. And of course by resouces i mean anything from .bmp to .fx files. (and .fx files are code, so im not trying to go douchebag, but i dont really consider C# a visual language :)
 
Top