Hey, im Keith and im 15 years old. I like computers alot and im pretty good at making websites, so this year i signed up for computer science. Our teacher is teaching us how to wrote programs using C++ and i love it, but i was wondering, why are they teaching us C++ when Java is alot more powerful and you can do alot more with it? Please correct me if im wrong, im new to the code language world :D.
Also, i was wondering if you can make cool graphics programs with C++ or only crappy triangles like we are learning? ( :-| )

Greetings kppowell,

I'm glad you have asked this question. Here is a detailed explanation between the differences of the two languages:

Differences between C++ and Java
Although the Java language is modeled on C++, it has several fundamental differences. It is important to keep in mind (for now) one fact: Java was designed to allow portable applications to be safely downloaded over a network. In its current form, it is not designed to replace C or C++ as a systems programming language. (this will not be true pretty soon).

There are a number of C++ features that Java does not support. Perhaps the single biggest difference between Java and C++ is that Java does not support pointers. In C++, pointer is one of C++ most important language features. It is also one of the most dangerous if used improperly. Pointers don't exist in Java for two reasons. First, pointers are inherently insecure. For example, using a C++ pointer, it is possible to gain access to memory addresses outside a program's code and data. Second, the designer of Java probably think that they were too troublesome. Since pointers don't exist in Java, neither does the -> operator.

Some key points

  • Java does not include structures or unions. These were felt to be redundant since the class encapsulates them.
  • Java does not support operator overloading as does C++.
  • C++ includes a preprocessor or support the preprocessor directives
    but Java does not.
  • C++ does perform automatic type conversions that result in a loss of precision. Java does not. &nbsp For example, a conversion from long integer to integer must be explicitly cast.
  • C++ allows default arguments. This means that you may specify a value that a parameter will have when there is no argument corresponding to that parameter when the function is invoked. Java does not allow default argument.
  • C++ supports inheritance of multiple superclasses by a subclass which Java does not.

New features added by Java
Java adds several features that C++ has no equivalent: packages, interfaces, and multithreading. There is no feature in C++ that directly corresponds to a Java package. The closest similarity is a set of library functions that use a common header file. The Java interface is somewhat similar to a C++ abstract class.

Multithreading allows two or more pieces of the same program to execute concurrently. There is no parallel for this in C++. If you need to multithread a C++ program, you will need to do so manually.

Java contains a built-in string type called String. String is somewhat similar to the standard string class type provided by C++. Of course, in C++ string is only available if you include its class declarations in you program. It is not a
built-in type.

While both C++ and Java support a Boolean data type, Java does not implement true and false in the same way as C++. In C++, true is any nonzero value. False is zero. In Java, true and false are predefined literals, and these are the only values boolean expression may have.

C++ supports exception handling that is fairly similar to Java's. However, in C++ there is no requirement that a thrown exception be caught. In Java, most exceptions must be caught.

I could go on, though I believe the difference has become clear. If you would like further information, please feel free to ask.


- Stack Overflow

thanks!
also, i downloaded dev-C++ BETA but i dont think it recognized
#include <iostream.h>
??
am i right? I ordered Code Warrior but its not going to be here for a while, please help!

Ah,

Glad to be of assistance.

> i dont think it recognized #include <iostream.h>
I've heard this from alot of programmers before. Though there is a difference between <iostream.h> and <iostream>.

Difference between iostream.h and iostream
iostream is somewhat more restrictive than the older iostream.h. One would possibly avoid problems by careful use of namespaces, but it would be a lot smarter to stick with one or the other.

On a futher note, iostream.h is deprecated (it was replaced when the C++ standard came out about 7 years ago)

Technically speaking, iostream.h is not considered depreciated, because it was never part of the official standard in the first place.

You should avoid using the *.h version as much as possible, because some implementations have bugs in their *.h version. Moreover, some of them support non-standard code that is not portable, and fail to support some of the standard code of the STL.

Furthermore, the *.h version puts everything in the global namespace. The extension-less version is more stable and it's more portable. It also places everything in the std namespace.

iostream.h is an old style method of including std C++ headers, and in opposite to iostream you don't have to declare that you're using the std namespace.

It is sometimes recommended to use:

#include <iostream>
using namespace std;

What does using namespace do?
Explained as simply as possible, namespaces allows us to group a set of global classes, objects and/or functions under a name. If you specify using namespace std then you don't have to put std:: throughout your code. The program will know to look in the std library to find the object. Namespace std contains all the classes, objects and functions of the standard C++ library.


Hope this helps,
- Stack Overflow

commented: Two very well written post, many thanks! +3

>iostream is somewhat more restrictive than the older iostream.h.
If by "more restrictive" you mean the requirement to qualify the std namespace when using a standard name. iostream is vastly more powerful and flexible than iostream.h and is more fully featured.

>iostream.h is deprecated
No, iostream.h is gone. It was completely removed when the language was standardized. Deprecated means that the feature is still supported but may be removed in future revisions.

>It is sometimes recommended to use
Of course a better recommendation would be either explicitly qualifying names that you intend to use with a using declaration:

using std::cout;

or with every use:

std::cout<<"blah blah"<<std::endl;

The using directive is no better than how iostream.h leaves every name in the global namespace.

Dude
Its first OO Language u r learning so have patience and learn it well(I know u will)
After this only Java comes....
n then u ll feel like ""Prince of Persia"....
so enjoy ur learning...
all the Best

The last post in this thread before yours was over four years ago. Can't you please leave dead threads alone?

I know i shouldn't be stretching it more but this is funny .. I'm sure the OP would have become quite a programmer by now... prince of persia :) ...

because c,c++ are the languages which are the base for learning other languages

commented: don't bump old threads +0

because c,c++ are the languages which are the base for learning other languages

Just over a week late or I could have celebrated my previous post's anniversary !! Leave this thread alone, it's too old now.

because it is a base language related to c# and java and u can clear your concept thrugh this language and can also be get more knowledge

commented: Did you read the prior 2 posts? +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.