![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: UK
Posts: 214
Rep Power: 3
![]() |
Re: how to tell C++ from Java source code?
|
|
|
|
|
|
#12 |
|
Programming Guru
![]() |
Re: how to tell C++ from Java source code?
10 points to BigK!
(And I guess Seif too.) |
|
|
|
|
|
#13 |
|
Hobbyist Programmer
Join Date: Oct 2006
Posts: 204
Rep Power: 2
![]() |
Re: how to tell C++ from Java source code?
I can't imagine how useful knowing whether or not you're looking at c++ or java could possibly be. That being said, I also don't agree with some of posters in here. If your job requires you to know something, and we tell you... who cares how you learned it, if you know it? Its not cheating for exactly that reason... as long as you know what your job requires you to know, then great. I doubt your employer cares how you learned it. No amount of information we tell you will change that.
1) Like Big K said, the 'main' method is declared as public static void main(String[] args). Some indicators that this is Java code are: -The keyword 'static', which indicates that a method is for the whole class, not for one particular object of that class. 'static' is also in c++, I think, so beware.. but you wouldn't see it used along with the main method. - the statement 'String[] args', because in C++, it would look like "int main(int argc, char *argv[])". String[] args is an array of String objects in Java. C++ might use Strings as well, so don't generalize this information... but it is useful to know that the statement String[] args in the main method definition means its Java and not C++. 2) In c++ code you will see pointer dereferencing and you will see address assignment. How will you know if you are seeing these things? the symbol & = address assignment and the symbol * = dereferencing. The basic idea is that if you have the address of something stored in a variable, using the * symbol will dereference it, i.e., it will get you the value of whatever is stored at that address. You will not see the use of these in Java programs because Java does not allow the programmer access to either of these operations. Use of these might look like int* myVariable; myVariable = &myOtherVariable; ^^ In this case, the '*' symbol just means it IS a pointer to another location, and CAN be dereferenced... not that you are actually dereferencing it. *myVariable = 15; ok I'm bored now so. Hope that helps. If my code example was off, anyone, feel free to correct it. In any case, you would not see use of those symbols in a Java program, since Java does not support them. There are other words you'd see in cpp but not Java, such as 'Cout' and 'Cin' |
|
|
|
|
|
#14 |
|
Newbie
Join Date: Apr 2005
Location: NC,USA
Posts: 17
Rep Power: 0
![]() |
Re: how to tell C++ from Java source code?
Re: how to tell C++ from Java source code? The c code won't execute through the java compiler duh...
import # |
|
|
|
|
|
#15 |
|
Hobbyist Programmer
Join Date: Oct 2006
Posts: 204
Rep Power: 2
![]() |
Re: how to tell C++ from Java source code?
His question was asking how to tell by looking at it, not by attempting to run it.
|
|
|
|
|
|
#16 |
|
Not a user?
Join Date: Sep 2007
Posts: 256
Rep Power: 2
![]() |
Re: how to tell C++ from Java source code?
|
|
|
|
|
|
#17 |
|
Newbie
Join Date: May 2008
Location: teh interwebz
Posts: 22
Rep Power: 0
![]() |
Re: how to tell C++ from Java source code?
true, but the original question was just between Java and C++.
__________________
iEngage |
|
|
|
|
|
#18 |
|
Newbie
Join Date: May 2008
Posts: 11
Rep Power: 0
![]() |
Re: how to tell C++ from Java source code?
|
|
|
|
|
|
#19 | |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 532
Rep Power: 4
![]() |
Re: how to tell C++ from Java source code?
Quote:
You turn a one-programmer shop into a million-programmer shop for free by doing that.
__________________
I Like Ike. Vote for Dwight Eisenhower this November. --This message brought to you by the the Procrastinators Club Of America. |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Presenting source code within html | Wizard1988 | Other Web Development Languages | 21 | Mar 20th, 2007 8:37 PM |
| java code question | lakitu | Java | 5 | Mar 6th, 2006 6:53 PM |
| Different IDE's Different code | 357mag | Java | 1 | Mar 26th, 2005 3:42 PM |
| Game ideas and source code | code10 | Coder's Corner Lounge | 1 | Mar 19th, 2005 11:24 AM |