Identifiers

names of variables, functions, user-defined types (structs and classes)

Rules of an identifier: enforced by compiler:

Exs.
num1
best_score   bestscore  bestScore        3 different names
main  Main  MAIN        3 different names.  only main is special
if  If  IF		3 different identifiers.  Only if is keyword

Always use names that are as meaningful as possible to aid human understanding of the program. Program as communication between human and computer and between humans.

Compiler knows nothing about English or the world. It only knows what you tell it to do, it doesn't know your purpose or your intention.

Keywords: Need to be aware so that you don't try to create variables with these names

From C:
auto		break		case		char		const
continue        default		do		double		else
enum		extern		float		for		goto
if		int		long            register	return
short		signed		sizeof		static          struct
switch		typedef		union		unsigned	void
volatile	while

C++ additions:
asm		catch		class		delete		friend
inline          new		operator	private
protected	public		template        this		throw
try		virtual

ANSI C++ additions:
bool            false           static_cast     using
const_cast      mutable         true            wchar_t
dynamic_cast    namespace       typeid          
explicit        reinterpret_cast                typename
Note that cin, cout, main are not keywords. But don't make variables with those names.

Next (data declarations)


©2000 David Wills