LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   C++ tutorial (link) (https://www.linuxquestions.org/questions/programming-9/c-tutorial-link-335517/)

goosie 06-20-2005 03:52 PM

C++ tutorial (link)
 
Ok, i just started myself and I started in C++ and found this tutorial:
http://www.cprogramming.com/tutorial.html
its easy to follow, so i figured i'd post it on here (even though its already been posted before...) just to help out anyone else who is interested in starting.

mandrakelinux 06-20-2005 06:10 PM

thanks goosie
may i'll follow you to learn c++ but still want to know something

goosie 06-20-2005 07:23 PM

i just started today and after searching for tutorials that seems to be the clearest one... i made a papers scissors rock game :D just finished it :D i love my game...

graciejj_82 03-11-2006 09:00 PM

I'm trying to learn c++ as well.

I followed your link. It seems to have a TON of information. but when I try to compile to first program, i get a bunch of errors.

The code is:
#include <iostream>

using namespace std;

int main()
{
cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
cin.get();
}


i type in this at the terminal:
gcc f.cpp -o hello

and I get the following errors:
/tmp/ccpI2yKM.o(.text+0x19): In function `main':
: undefined reference to `std::cout'
/tmp/ccpI2yKM.o(.text+0x1e): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccpI2yKM.o(.text+0x29): In function `main':
: undefined reference to `std::cin'
/tmp/ccpI2yKM.o(.text+0x2e): In function `main':
: undefined reference to `std::basic_istream<char, std::char_traits<char> >::get()'
/tmp/ccpI2yKM.o(.text+0x5a): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccpI2yKM.o(.text+0x89): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccpI2yKM.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status


I'm using fedora core 2, and I'm almost certain I've used gcc in the past and made it work, maybe I had to much Amaretto that night...?

jtshaw 03-11-2006 09:44 PM

Either compile like this:

gcc -lstdc++ f.cpp -o hello

or like this:

g++ f.cpp -o hello

The linking errors come from the fact that when you use gcc instead of g++ it doesn't automatically link against the standard c++ libraries and thus it can't find the iostream stuff.

graciejj_82 03-12-2006 08:37 AM

WONDERFUL!!! g++ f.cpp -o hello worked great! Thanks alot.


All times are GMT -5. The time now is 09:29 AM.