xersi xersi - 6 months ago 31
Linux Question

New keyword is used as an identifier

I am looking for C++ code to get getch() and getche() functions for linux. I briefly looked at the code and I saw that they are using the

keyword just like an identifier.

Here is the link :
What is Equivalent to getch() & getche() in Linux?

static struct termios old, new;
tcsetattr(0, TCSANOW, &new); /* use these new terminal i/o settings now */

Could anyone explain how it is possible? Is it valid C++ code? Thanks.


This is valid C code but it is not valid C++.

new is a keyword in C++ and cannot be used as an variable name.