Hey, I read in the Thinking in C++ book that C++ is essentially the same as Java. Is this so?
Hey, I read in the Thinking in C++ book that C++ is essentially the same as Java. Is this so?
Well, Java and C++ are very similar, but certain differences are too big for them to be called the same, one being how files are created, applets vs executables. They both have classes, but they use them in different ways. Third, Java can do what C++ can, but, it takes certain commonly used bits of code and wraps them into functions. For instance I believe there's one that is the equivilant to combining getch(); and return 0; (just a rough example, not exactly that same) Java is also more portable to the internet, for servers as well as web pages themselves can be generated by java, C++ can generate any kind of text (ie: web page code) you want it to, but you can't use it for web page interactivity like you can Java, so it's really what you're going to do with it that matters which language to choose, i recommend learning and using both, never hurts on a resume .
PHP and XML
Let's talk about SAX
actually C++ and Java are quite different... (even in syntaxis)
Java doesn't have global functions or variables they must be all wrapped in a class
Java is interpreted language and C++ is compiled language
(there is no such thing as Virtual C++ machine)
Java doesn't have pointers , C++ has
the concept of virtual methods in C++ is slightly different than Java's
Java has its implementation of methods inside class declaration only
C++ has outside and inside
and Java sux , C++ does not! )
Borko, isn't everything in Java, besides primitive types, a reference/pointer? The only difference is that you don't have to dereference them. (Don't worry, I'm probably wrong. )
>>Borko, isn't everything in Java, besides primitive types, a
>>reference/pointer? The only difference is that you don't have to
>>dereference them. (Don't worry, I'm probably wrong. )
Java has no primitives
even int is wrapped in a class
it also does not actually has 'arrays'
it has only 'vectors' of classes
for instance
in Java :
int array[20];
is not an array it is vector ...
and it can grow beyond 20...
>>...reference/pointer...
Yes every object is passed in refference manner to the methods
but still there are no pointers in Java...
There is a major difference between 'reference' and 'pointer'
they both access memory indirectly BUT references cannot be incremented, they allways 'reference' to a single object during their lifetime hence cannot be used for arrays like pointers can...
Java does have primitives. int, float, double, byte are primitives. The uppercase versions are the wrapper classes.
I am paraphrasing Eckel. I can post the table if you would like.
Saying they are similiar is true. However, they are by no means the same... I am suprised you got that impression from reading Eckel, his Thinking In Java book was very good.
I did understand what he meant. It is just that I am very bad at explaining myself. I put things in my own mental terms and don't really use appropriate wording.
Its funny how people get upset about what you just said It took me an afternoon to learn C++ because I knew both Cand JAVA very well. This would be speaking only in terms of programming though. Other than that they work very differently as far as how the interface with the OS. If anything, JAVA molded itself from C++ not the other way around.