Re: End-of-the-week fun

From: Moonlit (alt.spam_at_jupiter.universe)
Date: 11/08/03


Date: Sat, 8 Nov 2003 12:44:21 +0100

Hi,

Sswapping the array name and the subscript:

#include <iostream>

using namespace std;

int main()
{
  char A[6];

  memset( A, 0, sizeof A );
  A[5] = 'I' ;
  cerr << 5[A] << endl;

  return 0;
}

Regards, Ron AF Greve

"Dave" <better_cs_now@yahoo.com> wrote in message
news:vqof847v9ombcc@news.supernews.com...
> 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;
> }
>
>



Relevant Pages

  • Re: Tangled up in templates
    ... It works better if I define a default constructor ... > using namespace std; ... > Vector(int value) ...
    (comp.lang.cpp)
  • Re: [C] is ch = "Hello" usual?
    ... >reason to use naked pointers, ... using namespace std; ... int main { ...
    (alt.comp.lang.learn.c-cpp)
  • Re: why cant this be a feature in C++?
    ... Paul wrote: ... > int main ... > Is there any reason for not having some thing like this, ... Array with elements initialised with a non-default constructor was ...
    (comp.lang.cpp)
  • Weird output ?
    ... using namespace std; ... int SimpleCat::GetAge ... Constructor called. ... Destructor called ...
    (microsoft.public.vc.language)
  • Re: Explicitly calling the constructor
    ... The necessity was to place the scope operator in front of the constructor ... For some reason, this does not work ... > class CTestClass ... > int main ...
    (microsoft.public.vc.language)

Loading