|
-
Nov 21st, 2002, 01:45 AM
#1
Thread Starter
Junior Member
Borland Errors
#include <iostream.h>
int main()
{
cout<<"HEY, you, I'm alive! Oh, and Hello World!";
return 0;
}
Been looking through Tutorial sites and just copy pasted the code over everything and I get two error's when I try to run the program...
[Linker Error] Unresolved external '_Form1' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\PROJECT2.OBJ
[Linker Error] Unresolved external 'TForm1::' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\PROJECT2.OBJ
Any reason for this? Was there something I shouldn't have pasted over for it to run?
-
Nov 21st, 2002, 10:40 AM
#2
Stuck in the 80s
I don't know why you're getting the errors, but don't use <iostream.h>
Code:
#include <iostream>
using namespace std;
int main() {
cout << "HEY, you, I'm alive! Oh, and Hello World!";
return 0;
}
-
Nov 21st, 2002, 11:24 AM
#3
Monday Morning Lunatic
Most people using C++ Builder have trouble. It's not setup for "normal" C++ use, it assumes you're using the GUI (which is, obviously, not what you want in this instance).
Apparently there was a way, but I'd need a copy to work it out, and I can't be bothered to boot back into Windows again.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 21st, 2002, 11:59 AM
#4
Member
Well see this is how I do it for a Simple Hello World Proggy:
#include <iostream.h>
main() //notice no int before main, you dont need it
{
cout << "Hello Wolrd" << endl;
return(0); // notice brackets around 0
}
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Nov 21st, 2002, 12:04 PM
#5
Monday Morning Lunatic
6 mistakes:
1. <iostream> not <iostream.h>, the latter is deprecated.
2. No "using namespace std;" -- everything in the Standard C++ Library is within that namespace.
3. You *do* need the int. Implicit int was dropped because it caused trouble, and was totally incompatible with the type checking. It's since been dropped from C as well.
4. You misspelled "World".
5. No return statement is necessary in main(), and the parentheses aren't necessary either.
6. ( ) == Parentheses. [ ] = Brackets. { } = Braces.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 21st, 2002, 12:04 PM
#6
Stuck in the 80s
Originally posted by FunyBunyFartAHH
Well see this is how I do it for a Simple Hello World Proggy:
#include <iostream.h>
main() //notice no int before main, you dont need it
{
cout << "Hello Wolrd" << endl;
return(0); // notice brackets around 0
}
Why do you use iostream.h?
And if you're going all gung ho about not needing int before main, perhaps you will take notice that there's no need for brackets around 0.
-
Nov 21st, 2002, 12:06 PM
#7
Stuck in the 80s
Originally posted by parksie
...
You beat me to the punch, but regarding #5, I get a compiler error when not returning anything from main (when declared as int). What compiler do you use?
-
Nov 21st, 2002, 12:07 PM
#8
Stuck in the 80s
Originally posted by The Hobo
You beat me to the punch, but regarding #5, I get a compiler error when not returning anything from main (when declared as int). What compiler do you use?
I get that error in VC++. I just tried with Borland and no error.
So hats off to you. Just compiler differences.
-
Nov 21st, 2002, 12:08 PM
#9
Monday Morning Lunatic
GCC 3.2. VC++7 works as well.
The non-requirement for a return statement is part of the C++ standard -- if you don't return anything, the compiler is obliged to insert the equivalent to "return 0".
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 21st, 2002, 12:23 PM
#10
Member
My bad, its borland, I use visual, and my bad for the world spelling error ; /
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Nov 21st, 2002, 12:29 PM
#11
Stuck in the 80s
Originally posted by FunyBunyFartAHH
My bad, its borland, I use visual, and my bad for the world spelling error ; /
Regardless of your compiler, the code is still...crap.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|