ZURINET
asked on
Convert C++ Code to Java
Hallo all
I need to convert the attached code to JAVA
ps; Are there any converter tool/ tutorial /or guildline I can make use of
Thanks in Advance
I need to convert the attached code to JAVA
ps; Are there any converter tool/ tutorial /or guildline I can make use of
Thanks in Advance
class L2DTopology : public SOMLTopology
{
private:
long myHeight; //
long myWidth; //
L2DTopology() {}; //privatized to force proper construction
public:
L2DTopology(long Height, long Width)
{
myHeight = Height;
myWidth = Width;
};
virtual double LatticeDistance(long CellIndex1, long CellIndex2) const;
virtual unsigned long NumberOfCells() const { return (myHeight*myWidth); }
virtual ~L2DTopology() {};
};
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi CEHJ
Thanks for the input..
Just a question..
If I call the method
public /*unsigned*/ long numberOfCells()
{
return (height*width);
}
where would the height*width come from.. ?
Since the method numberOfCells() does not take any argument
Thanks for the input..
Just a question..
If I call the method
public /*unsigned*/ long numberOfCells()
{
return (height*width);
}
where would the height*width come from.. ?
Since the method numberOfCells() does not take any argument
it comes from the member vars provided to the constructor
private long height;
private long width;
private long height;
private long width;
You're also going to need the SOMLTopology class
And you'll need to subclass L2DTopology to actually use it.
And you'll need to subclass L2DTopology to actually use it.
>>You're also going to need the SOMLTopology class
Not necessarily. Only if the whole original hierarchy needs modelling
>>where would the height*width come from.. ?
Since the method numberOfCells() does not take any arguments
>>
height and width are instance variables
Not necessarily. Only if the whole original hierarchy needs modelling
>>where would the height*width come from.. ?
Since the method numberOfCells() does not take any arguments
>>
height and width are instance variables
ASKER
Just one last help
If I have SOMLTopology see below..
If I have the java code.. I can do the rest..
Thanks in Advance
If I have SOMLTopology see below..
If I have the java code.. I can do the rest..
Thanks in Advance
class SOMLTopology
{
public:
SOMLTopology() {};
virtual double LatticeDistance(long CellIndex1, long CellIndex2) const =0;
virtual unsigned long NumberOfCells() const =0;
virtual ~SOMLTopology() {};
};
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
and your othr class should be:
public abstract class L2DTopology extends SOMLTopology {
you could probably make SOMLTopology an interface actually
public abstract class L2DTopology extends SOMLTopology {
you could probably make SOMLTopology an interface actually
ASKER
The message const =0;
is not relevant in Java?
is not relevant in Java?
nope
>>
The message const =0;
is not relevant in Java?
>>
No - there's no equivalent in Java
The message const =0;
is not relevant in Java?
>>
No - there's no equivalent in Java
Java2D already has a heaps of classes you may be able to use instead