Write a program that shows a constructor passing information about constructor failure to
an exception handler after a try block.
What do i really need to do ?
Jump to Post#include <iostream> #include <string> class Foo { public: Foo() { throw std::string ( "poop" ); } }; int main() try { Foo f; } catch ( const std::string& msg ) { std::cerr<< msg <<'\n'; }
#include <iostream>
#include <string>
class Foo {
public:
Foo() { throw std::string ( "poop" ); }
};
int main() try
{
Foo f;
}
catch ( const std::string& msg ) {
std::cerr<< msg <<'\n';
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.