I'm working on translating a small package from C++ to Java. I've never really used C++, so some of the syntax is a bit of a mystery. In particular, I'm having difficulty working out what the Java equivalent to this would be:
file: SomeClass.cpp
SomeClass::SomeClass( BitStream* data, const char* const filename ) :
data( data ), cipher( filename ), iv( new Botan::byte [cipher.BLOCK_SIZE] ),
ivBitsSet( 0 ), keyMaterialRemaining( 0 ), keyMaterial( new Botan::byte [cipher.BLOCK_SIZE] ) {}
I'm happy with (in Java):
public SomeClass{
public SomeClass(InputStream data, String filename){
}
}
but I'm not sure what to do with the stuff after the :
in the C++. Are they fields? Optional parameters? Apologies for trivial question, but haven't got far with Google on this...
Everything after ":" is called the member initialization list, in C++ this is one way of initialising the members of this class. For example from your code, "data" is a member of SomeClass, so the equivalent in Java would be a simple assignment in the body of the constructor.
this.data = data;
etc. for all the other members
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With