C++ Fundamentals / PDF
C++ Fundamentals / PDF
l-value = expression;
const int totalDays = 25567; // NOT an l-value
Sample of the PDF document
C++ is based on C; in fact, C is almost a subset of C++
- Developed by Bjarne Stroustrup at AT&T Bell Laboratories
Standard C++
- Was formally adopted by American National
Standards Institute and ISO to provide a common base in 1998 - our course is
based on C++ as represented by “The C++
Programming Language”, Third Edition by B. Stroustrup
- Is unambiguous and machine independent.
- C++ implementations for a specific machine or
operating system usually
provide "extensions" to the standard. The use of such extensions will reduce the portability of the resulting C++ code.
provide "extensions" to the standard. The use of such extensions will reduce the portability of the resulting C++ code.
- Is not yet fully supported by any widely-used compiler.
Syntax and Semantics
syntax (grammar)
rules that specify how valid instructions (constructs) are written
semantics rules
that specify the meaning of syntactically valid instructions
The syntax of an assignment statement requires
that you have:
l-value = expression;
where l-value
is something, like a variable, whose value can be changed, and expression is a valid C++ expression.
The semantic rule for an assignment statement
specifies that the value of the expression
on the right side is stored in the l-value
on the left side. For example:
const int totalDays = 25567; // NOT an l-value
int daysPassed; // l-values
int daysLeft;
daysPassed = 17094;
daysLeft
= totalDays - daysPassed;
C++ Reserved Words
The C++ Standard specifies certain symbols and
words as the official "vocabulary" of the C++ language.
These reserved words (and symbols) are preempted by
the C++ language definition and may only be used in the manner the language
rules specify.
Fortunately the number of reserved words is
relatively small (< 300). Here's a
sample:...........
C++ Fundamentals / PDF
0 commentaires: