-
convert c++ to java
is there any free program out there that converts C++ programs into java?
-
hmmmm....Google is your best bet...but I would be highly suspicious of this sort of thing. Automatically converting programming languages is not a particularly easy thing to do, especially if the converted code ever has to be maintained.
The problems are caused by somethings be very difficult to express in some languages and easy in others. Java/C++ differences include:
* Concept of 'const'
* Pointers
* Multiple inheritance
* Pointers
* Templates (until the next versino of Java)
* Libraries (there isn't quite the level of standardization in C++)
* Machine dependancy
ArchAngel.
O:-)
-
thanks for the info. i tried searching the net but i didn't find any, expect for a couple that had to be bought. I just need the following code to be converted:
Code:
#include <iostream.h>
#include "LinkedList.h"
#include "mystring.h"
template <class Object>
void printList(const List<Object> & theList) {
if(theList.isEmpty())
cout << "The List is Empty, Dude!!" << endl;
else {
ListItr<Object> itr = theList.first();
for( ; !itr.isPastEnd(); itr.advance())
cout << itr.retrieve() << " ";
} //printing list in else statement
cout << endl;
} // print list
int main() {
string x;
List<string> myList;
ListItr<string> theItr = myList.zeroth();
int i = 0;
printList(myList);
cout << "Enter string values, seperated by whitespace." << endl;
cout << "ctrl-d by itself on a line will terminate the process." << endl;
cout << "Watch the List Building Up in Progress!!" << endl;
while (cin >> x) {
myList.insert(x, theItr);
printList(myList);
theItr.advance();
i++;
}
cout << endl;
cout << "Traverse the Entire List.Remove the names(nodes) that begin with
the character" << endl;
cout << "\"a\"" << endl;
cout << "Watch the List Shrink" << endl;
cout << endl;
string y;
string a = "a";
ListItr<string> tItr = myList.first();
for( ; !tItr.isPastEnd(); tItr.advance()) {
y = tItr.retrieve();
if(y[0] == a[0]) {
myList.remove(y);
printList(myList);
}
}
return 0;
} //main
I've never learned C++ before, so Im lost 
[ArchAngel added CODE tags]
-
The code you've posted is a perfect example of what I was talking about.
Code:
template <class Object>
This is a template declaration - we won't have these until JDK 1.5.
However, the meaning of the program is clear enough, why bother converting it at all? You should either know what it does or you should run it, see how it behaves and then write a Java program that behaves the same way.
ArchAngel.
O:-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|