D
Dave
TGIF!!!
I don't know if people will be interested in this or not, but if so, we
might learn a few interesting tidbits!
What are some of the most obscure features of the language you know of?
Please exclude anything that's not strictly part of the standard, even if a
very common extension. This can be in the core language itself or in the
standard library.
In addition to the obscure feature, a reason for its existence, if known,
would also be very interesting to hear!
I'll throw out a couple:
1. Constructor and destructor names may be surrounded by parenthesis. i.e.
(~MyClass)( ) {...}
2. When trying to match an exception to a catch clause, user-defined
conversions via a one-argument constructor are not used. The short program
below prints "Point 2".
Unfortunately, I don't know the reasons for these. Item 1 may not have a
real compelling reason, but surely item 2 does. I'd be very interested to
hear the reason for this behavior if anybody knows...
#include <iostream>
using namespace std;
class foo_t
{
public:
foo_t(int) {}
(~foo_t)() {}
};
int main()
{
try
{
throw 45;
}
catch(foo_t)
{
cout << "Point 1" << endl;
}
catch(int)
{
cout << "Point 2" << endl;
}
return 0;
}
I don't know if people will be interested in this or not, but if so, we
might learn a few interesting tidbits!
What are some of the most obscure features of the language you know of?
Please exclude anything that's not strictly part of the standard, even if a
very common extension. This can be in the core language itself or in the
standard library.
In addition to the obscure feature, a reason for its existence, if known,
would also be very interesting to hear!
I'll throw out a couple:
1. Constructor and destructor names may be surrounded by parenthesis. i.e.
(~MyClass)( ) {...}
2. When trying to match an exception to a catch clause, user-defined
conversions via a one-argument constructor are not used. The short program
below prints "Point 2".
Unfortunately, I don't know the reasons for these. Item 1 may not have a
real compelling reason, but surely item 2 does. I'd be very interested to
hear the reason for this behavior if anybody knows...
#include <iostream>
using namespace std;
class foo_t
{
public:
foo_t(int) {}
(~foo_t)() {}
};
int main()
{
try
{
throw 45;
}
catch(foo_t)
{
cout << "Point 1" << endl;
}
catch(int)
{
cout << "Point 2" << endl;
}
return 0;
}