Understanding exceptions in a constructor (by the conversion C-string to long example) I myself is a Java-developer and now I'm trying to understand how to do it in the most efficient way in C++. After reading that answer I decided to write the following:

//Headers omitted
class integer_validator
{
public:
    integer_validator(const char* const str);
    bool is_valid();
    long get_number();
private:
    bool valid;
    long result;
};

integer_validator::integer_validator(const char* const str)
{ 
    char *endptr;
    result = strtol(str, &amp;endptr, 10);
    if(*endptr == '\0') valid = true;
    else valid = false;
}

bool integer_validator::is_valid()
{
    return valid;
}

long integer_validator::get_number()
{
    if(!valid)
        throw std::exception();
    return result;
}
int main ()
{
    integer_validator vv("123123");
    integer_validator v("123123a");
    std::cout &lt;&lt; vv.get_number() &lt;&lt; std::endl; //prints the number
    std::cout &lt;&lt; v.get_number() &lt;&lt; std::endl;  //throws the exception
}


DEMO

And it works perfectly fine. But I'm not sure about some things I did. Is it considered good to put any piece of logic into a constructor? I actually do the validation within the constructor's body and I use only the C-functions. 

So should I be afraid of throwing an exception during the construction in that case?
From the c++ specification's point of view a constructor is allowed to throw an exception (in opposite to destructor). So your code is fine.

On the other hand I don't see any advantage why it should be validated directly in the constructor. You could do it in is_valid method as well. Furthermore, if you moved the valifation code out from the constructor to a private method, you would gain an easy way to keep responsibility of handling low-level exceptions inside you class.
So, although your code is valid semantically, its design needs some improvement.

I hope I helped:)