BaseArray et al as class members and so on
-
On 13/05/2015 at 17:39, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R16
Platform: Windows ; Mac OSX ;
Language(s) : C++ ;---------
While I have looked at the examples and documentation, BaseArray/PointerArray are giving me issues when one is used as a class member and it should be able to be passed to another class for iteration. The compiler says that it is inaccessible (even if in public: space). Could someone provide example code that shows how to accomplish this?For instance:
class MyClass { PointerArray<MyClass1> m_a_myclass1; .... PointerArray<MyClass1> GetMyClass1Array(); // or the best method to achieve this }; class MyClass2 { void DoSomething(MyClass* mc) { PointerArray<MyClass1> mc1 = mc->GetMyClass1Array(); .... } };
I've done similar in Java and with C++ STL but your system isn't being transparent enough to work as illustrated. Appreciate any help as I will need the power of this system soon enough.
Thanks,
-
On 14/05/2015 at 06:28, xxxxxxxx wrote:
You code does not work because you can not implicitly copy (and should not) PointerArray and other maxon arrays.
Of course you can still copy if you really sure that you need to do this costly operation using CopyFrom() function.Do you mean something like this ?
class MyClass1 { public: Int32 m_value; }; class MyClass { maxon::PointerArray<MyClass1> m_a_myclass1; //.... public: maxon::PointerArray<MyClass1>& GetMyClass1Array() { // or the best method to achieve this return m_a_myclass1; } const maxon::PointerArray<MyClass1>& GetMyClass1Array() const { return m_a_myclass1; } }; class MyClass2 { void DoSomething(MyClass* mc) { using maxon::PointerArray; if (mc == nullptr) return; PointerArray<MyClass1> &mc1 = mc->GetMyClass1Array(); for (Int i = 0; i < mc1.GetCount(); i++) { mc1[i].m_value = static_cast<Int32>(i); } //.... } };
> I've done similar in Java and with C++ STL but your system isn't being transparent enough to work as illustrated.
Java is not C++ !!! Please do not write C++ code like you do in Java.
You can copy STL container at will, no mater how costly (memory and time) this can be.Remo
-
On 14/05/2015 at 17:32, xxxxxxxx wrote:
Thanks for the example.
Well, of course, C++ is not Java. Java is pretty solid in the OOP area. C++ has been inching along attempting to scare itself into believing it is OOP when it ofttimes feels more like procedural C wrapped with some OOPy stuff. This is exactly how it was portrayed in the late 1990s and early 2000s. Books couldn't even break free of procedural and used classes almost like structs. It is why I leaped to Java and only moved to C++ because of the C4D SDK. C++ is improving but still has issues.
-
On 15/05/2015 at 04:20, xxxxxxxx wrote:
While you are right that C++ is not a "real" OOP language (unlike e.g. smalltalk being purely OOP) it is not meant to be (and never claimed to be) because system programming is also a target field of C++ from the very beginning (hence the C subset).
Since I used C# in a project I was quite ambushed how great it is (also concerning performance), but since C++11 (and C++14, C++17) there is really little left to argue about. It became a great and modern language set imo.