Realsoft-C objects are not 'C++' objects. C++ can be used for implementing Realsoft-C objects.
The main philosophical difference between C++
and Realsoft-C is the static nature of C++ versus the dynamic
nature of Realsoft-C.
As Realsoft-C is pure 'C' there is also differences in the syntax how objects get created and manipulated. The following table demonstrates the main differences between C++ and Realsoft-C API.
Table 7.1. C++ vs. Realsoft-C
| C++ | Realsoft-C |
|---|---|
sphere = new R3Sphere(); |
sphere = R3New(R3CLID_SPHERE,
R3TAG_END);
|
R3VECTOR center = {0.1, 0.0, 0.0};
R3FLOAT radius = 1.0;
sphere = new R3Sphere(center, radius);
|
R3VECTOR center = {0.1, 0.0, 0.0};
R3FLOAT radius = 1.0;
sphere = R3New(R3CLID_SPHERE,
R3T(R3SPHA_Center, ¢er),
R3T(R3SPHA_Radius, &radius),
R3TAG_END);
|
sphere->setCenter(center);
sphere->setRadius(radius);
|
R3SetAttrs(sphere,
R3T(R3SPHA_Center, ¢er),
R3T(R3SPHA_Radius, &radius),
R3TAG_END);
|
R3VECTOR center;
R3FLOAT radius;
center = sphere->getCenter();
radius = sphere->setRadius();
|
R3VECTOR center;
R3FLOAT radius;
R3GetAttrs(sphere,
R3T(R3SPHA_Center, ¢er),
R3T(R3SPHA_Radius, &radius),
R3TAG_END);
|
rc = sphere->foo("hello", c, r);
|
rc=R3DoA3(sphere, R3SPHM_FOO, "hello", &c, &r); |
// call with arbitrary number of args
rvalue = sphere->foo("hello", c, r, rgb);
|
R3Do(sphere, R3SPHM_FOO,
R3T(R3RA_Name, "hello"),
R3T(R3SPHA_Center, ¢er),
R3T(R3SPHA_Radius, &radius),
R3T(R3PRIMA_Color, &rgb),
R3TAG_END);
|
delete sphere;
|
R3Dispose(sphere); |
There is an example samples/kernel/cplusplus
demonstrating how to integrate C++ code into Realsoft-C.