0% found this document useful (0 votes)
18 views

Everything After The Comment Is A Comment

C++ 1.0 introduced several new features including: 1. Additional ways to write comments like // for single-line comments. 2. Variables can be declared anywhere in a block of code. 3. A bool data type was added to represent true/false values for conditions.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Everything After The Comment Is A Comment

C++ 1.0 introduced several new features including: 1. Additional ways to write comments like // for single-line comments. 2. Variables can be declared anywhere in a block of code. 3. A bool data type was added to represent true/false values for conditions.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Features/Changes of C++ 1.

Additional way of writing comments


// everything after the comment is a comment

Note:
/* this type of comment can still be used */

2. Variables can be declared anywhere 3. Data type bool - bool value may be true or false - relational operators produce a bool value - logical operators can work on bool values - can also be used as a controlling expression for if and loops 4. Input and Output statements - uses the header file iostream.h (include only iostream in preprocessing directive) and std namespace - All the files in the C++ standard library declare all of its entities within the std namespace. That is why the using namespace std; statement is included in all programs that used any entity defined in iostream. - cout (console output) Sample usage:
cout<< Hello world.;

<< - insertion operator


cout<< The sum is <<sum;

- end of line: \n or endl - setting precision for float values: Use iomanip.h
cout<<setprecision(2)<<4.278;

- cin (console input) Sample usage:


cin>>x;

>> - extraction operator

5. Reference parameters Instead of a function like below:


void swap(int *x, int *y) { int temp; temp = *x; *x = *y; *y = temp; } void main() { int a = 5, b = 10; swap(&a,&b); }

It is now:
void swap(int& x, int& y) { int temp; temp = x; x = y; y = temp; } void main() { int a = 5, b = 10; swap(a,b); }

6. Constant declarations
const float pi = 3.1416;

instead of
#define pi 3.1416

7. Constant reference parameters - declared by writing the keyword const before a reference parameter. This ensures that the programmer is guaranteed that the function can not change the value of the parameter.

You might also like