W
wij
Hi:
I encountered an expression B b(A()) which seemd to have no runtime
code compiled (as in the following example). Can anybody explain
this to me? Thank you.
// Build: g++ t.cpp (GCC version 3.4.2)
//
// [mypc]$./a.out
// strange?
// [mypc]$
//
#include <iostream>
class A {
public:
A() { std::cerr << "A ";
throw (const char*)"A_throw"; };
};
class B {
public:
B(const A&) { std::cerr << "B(A) "; };
};
int main(void)
{
try {
B b(A()); // constructing b object, no effect?
// expecting: "A_throw"
throw (const char*)"strange?";
}
catch(const char* str) {
std::cerr << str << '\n';
}
catch(...) {
std::cerr << "unknown\n";
};
return(0);
};
I encountered an expression B b(A()) which seemd to have no runtime
code compiled (as in the following example). Can anybody explain
this to me? Thank you.
// Build: g++ t.cpp (GCC version 3.4.2)
//
// [mypc]$./a.out
// strange?
// [mypc]$
//
#include <iostream>
class A {
public:
A() { std::cerr << "A ";
throw (const char*)"A_throw"; };
};
class B {
public:
B(const A&) { std::cerr << "B(A) "; };
};
int main(void)
{
try {
B b(A()); // constructing b object, no effect?
// expecting: "A_throw"
throw (const char*)"strange?";
}
catch(const char* str) {
std::cerr << str << '\n';
}
catch(...) {
std::cerr << "unknown\n";
};
return(0);
};