View Single Post
  #2 (permalink)  
Old 07-25-2007, 07:40 PM
rpgfan3233 rpgfan3233 is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jul 2007
Posts: 118
iTrader: (0)
rpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura about
The using keyword in C++ is similar to the import keyword in Java. However, using is used in combination with header files in C++. In Java, there is a default class path where the compiler automatically detects the java and javax packages, which pretty much eliminates the need for header files.

They are similar in that Java has the import statement to allow you to use things like java.io.InputStreamReader without the java.io. prefix, and C++ uses the using keyword to let you use things like std::cout without the std:: prefix.
However, they are different in that C++ requires you to use #include <iostream> to even use std::cout while Java lets you use java.io.InputStreamReader whether you imported it or not.

To answer your question, yes they are basically the same. If you imported java.io.InputStreamReader in Java, you could do a similar thing by including iostream and then using std::cin in C++. If you imported java.io.*, it would be slightly comparable to using namespace std, though using namespace std gives you access to everything within the std namespace whereas importing java.io.* only gives you access to classes and interfaces that are direct children of the java.io package, just as you can't use java.io things as just InputStreamReader without the io. prefix when you import java.*

I would recommend looking up a Java-C++ compare/contrast document like this one on a search engine.

__________________
"C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off."
-- Bjarne Stroustrup, creator of what is now known as C++
For more quotes by Bjarne Stroustrup, check out http://www.research.att.com/~bs/bs_faq.html#really-say-that.
Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to rpgfan3233 For This Useful Post:
HelloWorld (07-25-2007)