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 ?

#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';
}
commented: I've never seen the try-statement being used in this way :) +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.