I haven't touched C++ for 7 years, and I have a technical interview in 18 hours.

exotic syntax

But it's so fun! I tried to keep these relevant to syntax and not semantics.

 

What does it mean when you have a function that looks like void foo(int......)?

 

What is the type char(*(*s::*(*[3]))(int))[2]?

 

Given int foo(int a, int b) { return a ??!??! b; }, WTF does foo(2, 5) return? There's also a caveat here. What is it? (Not a nitpicky one.)

 

What is the output of the following program?

#include <iostream> 
int main(){<:](){std::cout<<"Hello";;%>;[:><%std::cout<<"Hello";;}();}

 

Is this valid? long int long typedef foo; Why or why not?

 

Given the macro #define foo(a, b) a, how would you define and use a function foo without undefining the macro?

 

Given #define foo(a, b) a##b, will the following compile, and what will it be after preprocessing? foo(,)

 

I'm running out of ideas, so an easy one:
Given int arr[5] = {};, what will 3[a] do and why?

 

When might you see the following?

template<typename T>
template<typename U>
template<>

What does the following line of source code do, if valid? [Blatantly stolen]

http://www.google.com

 

When is a function try block useful? (void foo() try {...} catch (...) {...})

 

What is the output of the following program?

#include <iostream>

int main() {
    int x = 1;    
    switch (x) {
        for (; x < 3; ++x) {
            case 0:
                std::cout << x;
                break;

            case 1:
                std::cout << x;
                continue;
        }
    }

    std::cout << x;
}
/r/cpp Thread Parent