primary expresion error

I'm a physics student. I'm not sure if this is the elegant solution

Also does the syntax differ with different versions like C++ Visual studio, which should I learn to become a professional programmer?
Can anyone recommend good, indepth, detailed books on C++. maybe C++ dissected?
thanks SO much!!


#include<iostream>
using namespace std;
int main()
{
string firstname, lastname;
cout << "Enter your first name:";
cin >> firstname;
cout << "Enter your last name:";
cin >> lastname;
cout << "Hello " << firstname ;
cout << " " << lastname<< endl;
return 0;
}


Last edited on
I'm not sure if this is the only problem with your code but below #include <iostream> you should add a line that says #include <string>

I'm fairly new to C++ as well, i've found the tutorial on this site useful. also C++ for Beginners by Herb Schildt

Hope that helps
As an aside, Herb Schildt has a bad reputation in the field of technical books.
Last edited on
I must admit I just used it for reference when i couldn't find what i needed in the tutorial, I understood the concepts before i used the book, just gave me some different commands from the tutorial so I could use more different things
thanks very much! I mean I have C++ Schaum's which is interesting
so what do books like C++ in 30 days have missing? is there one book that is like the ultimate C++ text?
I don't know of a single "ultimate c++ text". However, once you have learned c++ from any of several good introductions (the tutorial on this site, Patrick Winston's On To C++, etc), I think there is one correct choice for your second book: Effective C++, by Scott Meyers. I found it after years of c++ and most of it was new to me.
Here's Norvig's take on it. He explains it far better than I could.

http://norvig.com/21-days.html

Here's another take.

http://b.asset.soup.io/asset/0723/4939_e615_744.png

You may well be able to learn the syntax of C++ in 30 days, but that doesn't make you a programmer any more than being able to speak a language makes you a novelist.

is there one book that is like the ultimate C++ text?
The closest I've seen to such a thing is ISO/IEC 14882:2003 (supplanted JUST WEEKS AGO by ISO/IEC 14882:2011, the new C++ standard! Yay!). It is the definition of C++. However, being able to read it and understand it requires a significant amount of contextual knowledge and whilst I'd definitely recommend that a beginner sight it and know what it is, it's not the best to learn from and it certainly doesn't teach programming. That said, whenever I have a question about C++, it's where I look for the absolute, unequivocal definition of what C++ is.

Last edited on
Topic archived. No new replies allowed.