A few questions about C++

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2004
Posts: 2
Reputation: kppowell is an unknown quantity at this point 
Solved Threads: 0
kppowell kppowell is offline Offline
Newbie Poster

A few questions about C++

 
0
  #1
Sep 28th, 2004
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 .
Also, i was wondering if you can make cool graphics programs with C++ or only crappy triangles like we are learning? ( :-| )
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 185
Reputation: Stack Overflow is an unknown quantity at this point 
Solved Threads: 4
Stack Overflow's Avatar
Stack Overflow Stack Overflow is offline Offline
C Programmer

Re: A few questions about C++

 
0
  #2
Sep 28th, 2004
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
Following the rules will ensure you get a prompt answer to your question. If posting code, please include BB [code][/code] tags. Your question may have been asked before, try the search facility.

IRC
Channel: irc.daniweb.com
Room: #c, #shell
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 2
Reputation: kppowell is an unknown quantity at this point 
Solved Threads: 0
kppowell kppowell is offline Offline
Newbie Poster

Re: A few questions about C++

 
0
  #3
Sep 28th, 2004
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!
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 185
Reputation: Stack Overflow is an unknown quantity at this point 
Solved Threads: 4
Stack Overflow's Avatar
Stack Overflow Stack Overflow is offline Offline
C Programmer

Re: A few questions about C++

 
1
  #4
Sep 28th, 2004
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
Following the rules will ensure you get a prompt answer to your question. If posting code, please include BB [code][/code] tags. Your question may have been asked before, try the search facility.

IRC
Channel: irc.daniweb.com
Room: #c, #shell
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,625
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 715
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: A few questions about C++

 
0
  #5
Sep 29th, 2004
>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:
  1. using std::cout;
or with every use:
  1. std::cout<<"blah blah"<<std::endl;
The using directive is no better than how iostream.h leaves every name in the global namespace.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 5
Reputation: kaizen001 is an unknown quantity at this point 
Solved Threads: 0
kaizen001 kaizen001 is offline Offline
Newbie Poster

Re: A few questions about C++

 
0
  #6
Jan 21st, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,625
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 715
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: A few questions about C++

 
0
  #7
Jan 21st, 2009
The last post in this thread before yours was over four years ago. Can't you please leave dead threads alone?
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 441
Reputation: Agni is a jewel in the rough Agni is a jewel in the rough Agni is a jewel in the rough 
Solved Threads: 68
Sponsor
Agni's Avatar
Agni Agni is offline Offline
Posting Pro in Training

Re: A few questions about C++

 
0
  #8
Jan 21st, 2009
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 ...
thanks
-chandra
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC