CArraymyArray; myArray.Add(10); myArray.Add(20); myArray.Add(30); int count = myArray.GetCount(); cout << "Number of elements in the array is: " << count << endl;
CArrayThis example creates an array of strings called `myStringArray` and adds three elements to it. `GetCount()` is then called to return the number of elements in the array, which in this case is 3. In both of the above examples, the CArray class is from the MFC library.myStringArray; myStringArray.Add("apple"); myStringArray.Add("banana"); myStringArray.Add("orange"); int count = myStringArray.GetCount(); cout << "Number of elements in the array is: " << count << endl;