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
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’
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
<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’>
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.
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.