Usare eccezioni derivate da std::exception.
codice:class Prova { public: Prova(const std::vector<int>& values) { if(values.size()!=3) throw std::logic_error("vector size must be 3!"); a=values[0]; b=values[1]; c=values[2]; }; void view() { std::cout<<"\nvalore di a: "<<a; std::cout<<"\nvalore di b: "<<b; std::cout<<"\nvalore di c: "<<c; }; private: int a; int b; int c; }; int main() { try { Prova prova(std::vector<int> {1,2,3,4,5,6}); prova.view(); } catch(std::exception& e) { std::cout<< e.what() << std::endl; } }