Nokia Interview Test + exception constructor
This commit is contained in:
37
pod_constructor_optimization_for_array.cpp
Normal file
37
pod_constructor_optimization_for_array.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
struct A
|
||||
{
|
||||
int a;
|
||||
int b;
|
||||
|
||||
A()
|
||||
{
|
||||
std::cout << "A::A()" << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main ( void )
|
||||
{try{
|
||||
|
||||
A a[4];
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch ( const std::exception& e )
|
||||
{
|
||||
std::cerr << std::endl
|
||||
<< "std::exception(\"" << e.what() << "\")." << std::endl;
|
||||
return 2;
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
std::cerr << std::endl
|
||||
<< "unknown exception." << std::endl;
|
||||
return 1;
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user