hey,
What is the major difference between c and c++? and is it possible for me to learn c++ without learning c first?
Thanks
hey,
What is the major difference between c and c++? and is it possible for me to learn c++ without learning c first?
Thanks
Think carefully before just copying and pasting the commands your are advised into your terminal and clicking Enter, for more information about which ones not to use see this: http://ubuntuforums.org/announcement.php?f=73
1) C++ supports object-oriented programming in the language, C does not
2) Yes you can learn C++ without having prior C knowledge, anyway if you learn C++ you will learn C basics along the way because C++ is based on C
And what are the major usage of c++? c? And which one do u suggest i go with?
Think carefully before just copying and pasting the commands your are advised into your terminal and clicking Enter, for more information about which ones not to use see this: http://ubuntuforums.org/announcement.php?f=73
C++ in my opinion. Namely due to OOP allowing for more modular coding and a quicker crossover to other languages.
Also In my opinion, if you know C++ you can do C aswell.
I personnaly prefer C++. Even if you don't use the advanced features, being able to use stuff like namespaces, and using new/delete instead of malloc/free are IMO worth it.
Also, most big projects are written with OOP or at least with OOP-like techniques. It takes time to master but IMO OOP is a big plus
(some people say they don't like OOP, but in many cases - though not all - it's just because they don't master it. the main reason for going with C instead of C++ is simplicity)
I pasted this command in gedit:
#include<iostream>
using namespace std;
int main(void)
{
double dnumber1 = 0.0;
double dnumber2 = 0.0;
double dnumber3 = 0.0;
double daverage = 0.0;
cout<< "please enter 3 numbers!";<< endl;
cin>> dnumber1;
cin>> dnumber2;
cin>> dnumber3;
daverage = (dnumber1 + dnumber2 + dnumber3) /3;
cout<< "the average of the numbers are: "<< daverage << endl;
return 0;
}
and saved it as "c++.cpp"
Then when i tried to run it thru terminal this is what it said:
limac@limac-ubuntu:~$ cd ~/Desktop
limac@limac-ubuntu:~/Desktop$ g++ -o c++ c++.cpp
c++.cpp: In function ‘int main()’:
c++.cpp:12: error: expected primary-expression before ‘<<’ token
limac@limac-ubuntu:~/Desktop$
What went wrong???
Think carefully before just copying and pasting the commands your are advised into your terminal and clicking Enter, for more information about which ones not to use see this: http://ubuntuforums.org/announcement.php?f=73
where was that?
Think carefully before just copying and pasting the commands your are advised into your terminal and clicking Enter, for more information about which ones not to use see this: http://ubuntuforums.org/announcement.php?f=73
Bookmarks