Thanks,
Brenda R
[C++ Error] quarters.cpp(14): E2451 Undefined symbol 'cout'
[C++ Error] quarters.cpp(16): E2451 Undefined symbol 'cin'
/*brkittycat
February 20, 2004
Switch problem
quarters.cpp
*/
#include <iostream>
#include <conio>
void main()
{
int quarters;
cout << "How many quarters do you have?\n";
cin >> quarters;
switch (quarters)
{
case 0: cout << "Go back to the poor house!\n";
case 1: cout << "You have enough for a parking meter.\n";
break;
case 2: cout << "You have enough for a candy bar.\n";
break;
case 3: cout << "You have enough to buy a Bic pen.\n";
break;
case 4: cout << "You have enough to buy a soft drink.\n";
break;
default: cout << "You have enough to do my laundry. Let's go!\n";
break;
}
getch();
return;
}
/*How many quarters do you have?
7
You have enough to do my laundry. Let's go!
*/
You can #include <iostream.h>
Otherwise, add "using namespace std;" to the top of your code, or explicitly
specify "std::cout" and "std::cin".
-- YH --
--
Any e-mail sent to me from the newsgroups will be ignored. Please confine
your posts to the newsgroups and DO NOT reply to this e-mail account.
> Brenda,
>
> You can #include <iostream.h>
I wouldn't recommend this, as it's not standard C++ and won't
compile on a strict C++ compiler. This (with .h) exists only for
backwards compatibility.
>
> Otherwise, add "using namespace std;" to the top of your code,
I wouldn't recommend this either, except in a last, desparate
attempt. It undoes all the benefits of putting the standard library
in a namespace in the first place.
or explicitly
> specify "std::cout" and "std::cin".
This is what I'd recommend. <g> Virtually all names in the standard
library need to be qualified with std:: to access them.
--
Chris (TeamB);
If I remember correctly std::strlen and std::getchar illustrate this.
. Ed
> Chris Uzdavinis wrote in message
> news:j5znb41...@explicit.atdesk.com...
std::strlen and std::getchar
I am still wondering about incompatibility between Builder 5.02 and
Builder 6 Professional. It is very frustrating not to be able to bring
a .cpp file home from class and compile it using Builder 6.
Brenda
> or explicitly
>
>>> specify "std::cout" and "std::cin".
>
>
> This is what I'd recommend. <g> Virtually all names in the standard
> library need to be qualified with std:: to access them.
This is in Chapter 16 in my Forouzan and Gilberg text; we are only on
Chapter 5, and I am having difficulty, getting very frustrated trying to
compile with the Builder 6 Professional I bought. It is more powerful
than I need to write programs only slightly more complicated than
"Hello, World". I don't know what TForms are, and I don't really need
WIN32 API's. We are just writing programs that we can run in the DOS
Command Prompt. It was naive of me to think I would be able to work
with Builder 5.02 in class, and then come home and run things through
Builder 6 Professional without taking a lot of time to learn how to use
the software.
We have a spring break from classes next week. I will try to read
through your suggestion and test it out.
Thanks for your comments.
Brenda
You can #include <iostream.h>
I know the .h syntax for including the library is backwards, but I think
that worked. While working at school with Builder 5.02, compiles
failed, and adding in the .h to the #include statement got rid of the
error I was getting.
Otherwise, add "using namespace std;" to the top of your code
When I used the "using namespace std;" in my earliest problems in class
(with Builder 5.02), I got error messages. My instructor said our
textbook uses that statement in the early chapters, but hasn't taught us
how to use it yet, so I took it out and was able to compile the programs
I was working on. (We are using Forouzan and Gilberg text "Computer
Science, a Structured Approach Using C++".)
or explicitly specify "std::cout" and "std::cin"
This is in Chapter 16 in our book; we are only on Chapter 5.
We had a test Friday night, and the problem I successfully compiled
at school using Builder 5.02 would not compile at home using Builder 6
Professional (no revisions this time). Is there some reason that a .cpp
written using 5.02 won't compile using Builder 6?
Thanks again,
Brenda
. Ed
> Brenda R wrote in message
> news:4043c66d$1...@newsgroups.borland.com...
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
Tried to compile in Borland C++ Builder 6 Professional.
Did not get cin, cout errors I wrote about last Friday.
Must be the using namespace std;
For the time being I will have to remember to use it at
home, but not at school, at least until we learn how to use it.
Did get these errors, though.
> Build
> [Linker Error] Unresolved external '__InitVCL' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\LIB\CP32MTI.LIB|crtlvcl
> [Linker Error] Unresolved external '__ExitVCL' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\LIB\CP32MTI.LIB|crtlvcl
> [Linker Error] Unresolved external 'WinMain' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\LIB\C0W32.OBJ
Then took it to an open source compiler and got it to compile by adding
> #include <conio.h>
after I realized I had to add
> getch();
to my code because the Command Prompt window flashed on and off the screen.
Then I brought it back to Borland C++ Builder 6 Pro, and changed the
> #include <conio.h>
to
#include <conio>
Saved the file, and ran the compiler successfully. Finally.
Am I finally figuring this out?
Thanks,
Brenda