Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Most Keywords Possible In Declaration [closed]

Tags:

c++

keyword

Purely out of curiosity I have been wondering how many keywords can fit in a declaration. Assuming templates don't count(because infinity), the longest one I could come up with was:

extern const unsigned long int i;

I was trying to fit new in there too.

I looked this up a bunch, but didn't see anything about it. Just for fun!

EDIT- Since this is too broad of a question, how about you can only fit in a keyword once for each different keyword. No exceptions. Of course long long is a perfectly legitimate type, I just want to know how many different ones can be used together. So given that, how many keywords can fit in one declaration. Could be a function, member function, or variable.

like image 755
Leon Frickenschmidt Avatar asked May 26 '14 01:05

Leon Frickenschmidt


People also ask

How many keywords are in CPP?

There are 95 keywords in C++, of which around 30 are unavailable in the C language. Keywords are always used for a special purpose in a program, but we can't use them as variable or function names. Some examples of Keywords in C++ are break, int, void, public, private, auto, return and many more.

What are keywords in CPP?

Keywords (also known as reserved words) have special meaning to the C++ compiler and are always written or typed in short(lower) cases. Keywords are words that the language uses for a special purpose, such as void, int, public, etc. It can't be used for a variable name or function name.

What is declaration of variable in C++?

The variable declaration refers to the part where a variable is first declared or introduced before its first use. A variable definition is a part where the variable is assigned a memory location and a value. Most of the time, variable declaration and definition are done together.


2 Answers

Here is one that is practically infinite:

thread_local constexpr static const unsigned long long*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const*
const* const* const* const* const* const* const* const* i{nullptr};

Live Example

like image 189
David G Avatar answered Oct 16 '22 12:10

David G


You said declaration. Here's a function declaration with ten total in a messed up order for kicks:

int inline long constexpr volatile static unsigned const long foo() noexcept;

You can do twelve with a member function:

virtual int inline long constexpr volatile unsigned const long foo() const noexcept = delete;

I don't know how you'll take this, but I believe this to be a valid twenty on a variable declaration, not including possibilities for initialization (though not including that, but including decltype is questionable):

alignas(sizeof(decltype(typeid(const volatile unsigned long long int)))) static thread_local decltype(typeid(const volatile unsigned long long int).name()) foo{};

It's kind of hard to know what to keep away from when there are so many possibilities for infinite repetition. For example, my variable declaration has no casts, and this is why I said allowing decltype is questionable:

int i;
decltype(const_cast<const int &>(const_cast<int &>(const_cast<const int &>(i)))) foo{i};
like image 31
chris Avatar answered Oct 16 '22 13:10

chris