Compatability issues?

Hello, I am extremely new to Linux, I am running Ubuntu on my laptop, my problem is that I have a yearning to learn C++ programming. I have read some sources and I have deduced that g++ is the linux version of a C++ compiler. I don't know if this is correct. So hear goes.... I am hoping that it would be possible for me to use C/C++ Programmer's Bible to learn to program. I was curious if I can. The reason I believe there is a problem is because I have installed all the g++ components, when I compile in the terminal there are a lot of errors though I triple checked that I correctly typed the program. Also not only this but when I have been searching for the solution, I copied and pasted a couple of programs that users have written just to check the compatibility but to no success still errors! Please help!!!

P.s Please go easy on me, if I have made some glarringly obvious error I do apologise I do not want to waste anyone's time I am genuinely facing a wall and cannot find a way past. All help will be very much appreciated. Thank you
You'll need to show us the code and the command you are using to compile the program for us to help.
This is one of the program I have entered

#include <iostream>

using namespace std;

int
main (void)
{ int a = 3;
cout << "++a is: " ++a << " and a++ is: " << a++ << endl;

return 0;
}

It gives the error message as such

first.cpp: In function ‘int main()’:
first.cpp:8: error: increment of read-only location ‘(const char*)"++a is: "’
first.cpp:8: error: lvalue required as increment operand
first.cpp:8: error: expected ‘;’ before ‘a’

Thank you for your help
And
a lot of errors

is also not very helpful.

EDIT: oops. two minutes too late...
Last edited on
You're missing a << between "++a is: " and ++a.
Ah. And please use code tags.
Im not sure how to reply. But maybe if I tell you that I am writting the code in gedit text editor. then I am (I think) compiling it in the terminal (application -> accessories -> terminal. I am truly sorry that I am not been more useful. If there is any other way that I can help please say and I shall do it. Thank you
Did you read my second reply?
What is a code tag?............Sorry
My second reply.
I see, do you mean...

<first.cpp: In function ‘int main()’:
first.cpp:8: error: increment of read-only location ‘(const char*)"++a is: "’
first.cpp:8: error: lvalue required as increment operand
first.cpp:8: error: expected ‘;’ before ‘a’>

??
No. I meant
You're missing a << between "++a is: " and ++a.


I get the impression that you are not reading the answers to your questions at all.
Or are you just trolling?
Hello, no i am not trolling you asked me to use code tags, as i have no prior experience I ask mozilla and here we have <http://codex.wordpress.org/Writing_Code_in_Your_Posts> this is where i found (or thought) the ettiquet. I am not been purposely stupid, I dont consider myself so. What I am trying to establish is how to program C++ on ubuntu.
Well... Aem... I see...

't was nice meeting you.

I'm out.
This forum has it's own method for displaying code, which is to put [code]int main(); // etc.[/code] , which will be rendered as:
int main(); // etc.
In any case, the problem with your code was answered.
Topic archived. No new replies allowed.