Prev: reinterpret_cast
Next: Discards qualifiers
From: Bart van Ingen Schenau on 15 Feb 2006 14:36 Cheerful Pickle wrote: > > Thanks, I copied and pasted it into a new file, but, unfortunately, it > did not work for me, as the following testifies: > > [andy(a)localhost C++Lessons]$ gcc newsconversion.cpp You are invoking your compiler in the wrong way. <off-topic> The GCC package contains compilers for several different languages. The extension on the source-file determines which language the compiler will recognise, but the name that you use to invoke the compiler will determine which libraries will be included by default. With the .cpp extension, your source file will be compiled as a C++ source file. But, by using the name gcc to call the compiler, you are effectively saying that you only need the C libraries. To get the C++ libraries, you should use the name g++: g++ newsconversion.cpp </off topic> As it is off-topic for this group to discuss how to use a particular compiler, you should ask in a support group for your particular compiler if you want/need more information. Bart v Ingen Schenau -- a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq c.l.c FAQ: http://www.eskimo.com/~scs/C-faq/top.html c.l.c++ FAQ: http://www.parashift.com/c++-faq-lite/
From: Daniel T. on 15 Feb 2006 14:37 In article <pan.2006.02.15.17.36.32.624457(a)no.junk>, Cheerful Pickle <cp(a)no.junk> wrote: > > #include <cstdio> > > #include <iostream> > > > > int main(int nNumberofArgs, char* pszArgs[]) > > { > > using namespace std; > > // enter the temperature in Celsius > > int celsius; > > cout << "Enter the temperature in Celsius:"; cin >> celsius; > > > > // calculate conversion factor for Celsius // to Fahrenheit > > int factor; > > factor = 212 - 32; > > > > // use conversion factor to convert Celsius // into Fahrenheit values > > int fahrenheit; > > fahrenheit = factor * celsius/100 + 32; > > > > // output the results > > cout << "Fahrenheit value is:"; > > cout << fahrenheit; > > //system("pause"); > > > > return 0; > > } > > Thanks, I copied and pasted it into a new file, but, unfortunately, it did > not work for me, as the following testifies: > > [andy(a)localhost C++Lessons]$ gcc newsconversion.cpp > /home/andy/tmp/cch5C2Ja.o: In function `main': > newsconversion.cpp:(.text+0x25): undefined reference to `std::cout' When looking at the errors, it's generally best to try to fix just the first error then recompile. Many times, later errors are a result of the first problem. As may be obvious, your compiler can't find std::cout. My guess is that it is installed incorrectly. -- Magic depends on tradition and belief. It does not welcome observation, nor does it profit by experiment. On the other hand, science is based on experience; it is open to correction by observation and experiment.
From: Cheerful Pickle on 15 Feb 2006 15:02 On Wed, 15 Feb 2006 20:36:33 +0100, Bart van Ingen Schenau wrote: > But, by using the name gcc to call the compiler, you are effectively > saying that you only need the C libraries. To get the C++ libraries, you > should use the name g++: > g++ newsconversion.cpp Thank you. Thank you. Thank you. Thank you. Thank you. Thank you. g++ did it. Thanks, again. I was about to give up on it. Thank you. -- Andy Rugg The Cheerful Pickle
From: Old Wolf on 15 Feb 2006 20:30
Cheerful Pickle wrote: > I went out and bought a book on C++ programming, _C++ for Dummies_. There's a well-known typo on the cover of that book. It was supposed to be, "C++ by Dummies". When looking for C++ books, avoid anything by Schildt or Liberty. There are some book reviews at http://www.accu.org/ . |