#include <iostream>
#include <stdexcept>
#include <vector>
class ResourceManager {
private:
std::vector<int> data;
public:
void addData(int value) noexcept {
try {
data.push_back(value);
} catch (const std::bad_alloc&) {
// Handle allocation failure
std::cerr << "Memory allocation failed. Data not added." << std::endl;
}
}
void displayData() const noexcept {
for (const auto& item : data) {
std::cout << item << " ";
}
std::cout << std::endl;
}
};
int main() {
ResourceManager rm;
rm.addData(10);
rm.addData(20);
rm.addData(30);
rm.displayData();
return 0;
}