|
@@ -29,7 +29,7 @@ int Cat::HowManyCats = 0; // Initialize static data member
|
|
|
|
|
|
// Function to create an array of 5 Cat objects with ages 1, 2, 3, 4, 5
|
|
|
void creating() {
|
|
|
- std::cout << "before the Cat array is created, the number of the cat is:" << Cat::GetHowMany() << std::endl;
|
|
|
+ std::cout << "before the Cat array is created,the number of the cat is:" << Cat::GetHowMany() << std::endl;
|
|
|
|
|
|
Cat* cats[5]; // Array of pointers to Cat objects
|
|
|
|
|
@@ -38,7 +38,7 @@ void creating() {
|
|
|
cats[i] = new Cat(i + 1);
|
|
|
}
|
|
|
|
|
|
- std::cout << "after the Cat array is created, the number of the cat is:" << Cat::GetHowMany() << std::endl;
|
|
|
+ std::cout << "after the Cat array is created,the number of the cat is:" << Cat::GetHowMany() << std::endl;
|
|
|
|
|
|
// Delete the 5 Cat objects to free memory and reduce the count
|
|
|
for (int i = 0; i < 5; ++i) {
|
|
@@ -47,11 +47,11 @@ void creating() {
|
|
|
}
|
|
|
|
|
|
int main() {
|
|
|
- std::cout << "before the function, the number of the cat is:" << Cat::GetHowMany() << std::endl;
|
|
|
+ std::cout << "before the function,the number of the cat is:" << Cat::GetHowMany() << std::endl;
|
|
|
|
|
|
creating();
|
|
|
|
|
|
- std::cout << "after the function, the number of the cat is:" << Cat::GetHowMany() << std::endl;
|
|
|
+ std::cout << "after the function,the number of the cat is:" << Cat::GetHowMany() << std::endl;
|
|
|
|
|
|
return 0;
|
|
|
}
|