features

post Articles

(Articles)

search files, exploits & links sections:

online chat
 server:
   irc.xor.cx
 channel:
   #neworder

random article
Media's (mis-) Representation of Hackers - A Bachelor Thesis
Paris2KJun 6 2004

quotable quotes
Please do not shoot the pianist. He is doing his best.
Oscar Wilde

What Wrong With This Code? [C++]
@ What's Wrong With This Code     May 09 2005, 22:56 (UTC+0)
THA writes: What happens when a language encounters ambiguity involving new language features that might be mistaken for old language declarations?

Quite recently, I encountered this similiar piece of code that someone was having problems with:

class Test
{    public:
         Test(int y) {}
};

int main()
{   int x;
    Test(x);
}

This code actually exibits a rather subtle error involving declarations with the C++ language. The coder wanted to test the constructor, except the compiler keeps generating an error.
Identify the problem (why the compiler error) and offer a solution. Be as specific and as descriptive as possible with your solutions and explanations.

Resources:
GotW #1
Solution

read comments (37) / write comment

views: 5178   printer-friendly version

Top of page