Presentation is loading. Please wait.

Presentation is loading. Please wait.

Keywords.

Similar presentations


Presentation on theme: "Keywords."— Presentation transcript:

1 Keywords

2 Outline In this lesson, we will: Review keywords
Look at the list of all keywords Consider issues of using keywords as identifiers Review reserved identifiers

3 Keywords We have seen these identifiers that are reserved by the C++ programming language: return throw if else while for do break void signed unsigned bool true false char short int long float double struct const goto

4 Keywords These are also common English-language keywords:
and auto case catch class concept continue default delete explicit export friend import module mutable new not operator or private protected public register requires static switch synchronized template this try typedef union using virtual volatile

5 Keywords Other keywords are acronyms or abbreviations
alignas alignof and_eq asm atomic_cancel atomic_commit atomic_noexcept bitand bitor char16_t char32_t compl constexpr const_cast co_await co_return co_yield decltype dynamic_cast enum extern inline namespace noexcept not_eq nullptr or_eq reinterpret_cast sizeof static_assert static_cast thread_local typeid typename wchar_t xor xor_eq

6 Keywords Most programming languages have keywords
The C++ programming language has approximately 100 keywords The C programming language has only 32 Issue: because keywords are part of the language, the errors will appear very bizarre A unknown identifier has a straight-forward error message A keyword will see the compiler trying to understand the context in which that keyword should be used in

7 Reserved identifiers A gentle reminder
Reserved identifiers are for the use of the compiler, the standard libraries, etc. Any identifier starting with an underscore or containing to adjacent underscores is a reserved identifier If you use such a reserved identifier, your code may work, but it may also fail with the next update to the standard library, your compiler, etc.

8 Summary Following this lesson, you now:
Have been exposed to all keywords in C++ Know that you don’t have to memorize these Know that accidental use will result in significantly different error messages

9 References [1] No references?

10 Colophon These slides were prepared using the Georgia typeface. Mathematical equations use Times New Roman, and source code is presented using Consolas. The photographs of lilacs in bloom appearing on the title slide and accenting the top of each other slide were taken at the Royal Botanical Gardens on May 27, 2018 by Douglas Wilhelm Harder. Please see for more information.

11 Disclaimer These slides are provided for the ece 150 Fundamentals of Programming course taught at the University of Waterloo. The material in it reflects the authors’ best judgment in light of the information available to them at the time of preparation. Any reliance on these course slides by any party for any other purpose are the responsibility of such parties. The authors accept no responsibility for damages, if any, suffered by any party as a result of decisions made or actions based on these course slides for any other purpose than that for which it was intended.


Download ppt "Keywords."

Similar presentations


Ads by Google