Java links are much closer to C ++ pointers than to C ++ links. In Java, you can do the following with a link:
- Change which object it belongs to
- Check if two links are equal or not equal:
- Send messages to the specified object.
In C ++, pointers have the same properties. As a result, the code you are looking for in C ++ is similar to
float* f = new float;
This is completely legal. For a better comparison, this Java code:
String myString = new String("This is a string!");
will display this code in C ++:
std::string* myString = new std::string("This is a string"); std::cout << myString->length() << std::endl; delete myString;
Hope this helps!
source share