• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

basic difference between c++ and java

 
samdeep aarzoo
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the basic diffrence between c++ and java
both :are compiler based language
use :class concept
java uses: jvm compiler
c++ use : turboc++ compiler

both are bject oriented language
in java everything :is object except datatype
than it mde them also wrapper class.
object oriented issues
1. inheritance : parent to child
2. polymorphism : dynamic binding
3. encapsulation : hiding

so my question is :
which language whether c++ or java is more object oriented
in which language we can wisely use reuasble object
 
Ashok George
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ...
here are my understandings please reply!!!

C++ is not purely an Object Oriented language(OOL)
if aloanguage has to be OOL then it should not support Global functions and Global Data but C++ supports such global things...
and in OOL every thing muct be Objects

java is 99.99% OOL(pure)

it is said so coz in java Primitive data types are not objects!!!

java codes are portable i mean platform independent
whil c++......


THE Other difference is in the case of NAMESPACES!!!.. i am still reading about it!!!

i am not sure !!! of my answers....
just my curiosity made me there!!!
just!!! reply guys!!!
 
Nigel Browne
Ranch Hand
Posts: 703
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read This
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both C++ and Java have OO features. What matters more than which one has more is how you use those features. In both languages you can write completely procedural code, so even if language A is more OO than language B, any given program written in A might be less OO than another program written in B.

As to the mode of execution (interpreter, compiler, VM, some mixed form), that's largely independent of the language. C/C++ tends to be compiled to native code, Java tends to be compiled to byte code, which is then either interpreted or compiled to native ocde or both at the same time. Other modes are possible for both languages, and they do exist, even if they are largely irrelevant outside of R&D.

i am not sure !!! of my answers....

In that case, maybe you should use fewer exclamation marks
 
Rick O'Shay
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java and C++ have little in common so it's easier to describe where they are alike. Java syntax has a significant overlap with C++ programming syntax. By significant I mean enough to make a line of Java code look familiar to a C++ developer. There was a time when the majority of Java developers were active C++ developers, gradually migrating.

Java is more OO as there are no loose functions or variables declared outside the context of a class definition. C++ can be used to write superior C code that can be compiled directly by an ANSII C compiler. C is entirely procedural.

Interesting side note is that creating object oriented (small 'o') programs in C was an extremely popular and sucessful design pattern. C languages allowed the definition of data records called structs -- short for structure. Skilled software engineers would always define data structures then build functions that operated specifically on those data structures. They would then be delivered as a unit. It was surprisingly simple for the skilled C programmer to move to C++. C++ was just formalizing what they had always done in a more convenient way.
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
c++ is much more closer to the implementation of object-oriented theory, as it allows multiple inheritance
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
c++ is much more closer to the implementation of object-oriented theory, as it allows multiple inheritance


OO is not a theory like relational databases are - it's more of a set of concepts. One of those is inheritance, which Java supports. Whether multiple inheritance is a "truer OO" is very much up for debate.
 
Rick O'Shay
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>> c++ is much more closer to the implementation of object-oriented theory: allows multiple inheritence.

It's not a generally accepted requirement for object-oriented languages, but Java certainly has it. Java does not have the ability to write an application that uses no object oriented features whatsoever; C++ definitely does.

There are only two issues that I miss from C++ with respect to Java and neither is object-oriented:

1. A more general const modifier:

int safeMemberFunction( String bar ) const

2. Default arguments:

int foo( int x, int y = 0, int z = 0 ) ...

Item one allows for much safer more robust programs.
Item two eliminates this sort of thing:

int foo( int x )
int foo( int x, int y )
int foo( int x, int y, int z)

Variable argument lists are an OK work around.
 
Rick Portugal
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rick O'Shay:
Java and C++ have little in common so it's easier to describe where they are alike. Java syntax has a significant overlap with C++ programming syntax.
Sounds like a contradiction to me. Syntactically, the languages have a lot in common. In practice, the most obvious differences are that C++ allows the developer to use pointers (and pointers to pointers, etc.) and Java does not. Advantage Java. Pointers have been a common source of hard-to-spot bugs.

Also, C++ uses contructors like Java, but C++ also has the concept of DEstructors to delete objects. Java has a garbage collector instead, so the potenial for memory leaks is much less.
 
samdeep aarzoo
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is
using pointers in c++
gives more advantage to c++ over java
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic