#include "nsTArray.h" // Create an nsTArray object to hold integers nsTArraymyArray; // Add some integers to the array myArray.Append(10); myArray.Append(20); myArray.Append(30);
#include "nsTArray.h" class MyClass { public: int x; }; // Create an nsTArray object to hold objects of MyClass nsTArraymyArray; // Create some objects of MyClass and add them to the array MyClass obj1 = {10}; MyClass obj2 = {20}; MyClass obj3 = {30}; myArray.Append(obj1); myArray.Append(obj2); myArray.Append(obj3);
#include "nsTArray.h" #includeThe nsTArray class is defined in the NSPR (Netscape Portable Runtime) library.// Create an nsTArray object to hold integers nsTArray myArray; myArray.Append(10); myArray.Append(20); myArray.Append(30); // Iterate over the elements of the array and print them to the console for (auto i = myArray.Begin(); i != myArray.End(); ++i) { std::cout << *i << std::endl; }