This shows you the differences between two versions of the page.
|
cpp:define:start [2014/03/18 13:49] 94.139.29.72 sorry was no cut and paste .. http://ideone.com/RBtZkV copy that from this page |
— (current) | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== #define ===== | ||
| - | |||
| - | <code cpp> | ||
| - | #define cpp cout << "C++" << endl; | ||
| - | </code> | ||
| - | |||
| - | #define is used for creating names that will overwrite the current event. | ||
| - | |||
| - | For example: | ||
| - | |||
| - | <code cpp> | ||
| - | |||
| - | // we are going to make a program that will use a #define for replacing a number | ||
| - | |||
| - | #include <iostream> | ||
| - | #include <cmath> | ||
| - | |||
| - | #define INT_FIVE int i = 5; | ||
| - | #define DOUBLE_FIVE double d = 5; | ||
| - | |||
| - | int main() { | ||
| - | |||
| - | cout << "The normal square root of 5 is: " << sqrt(DOUBLE_FIVE) << endl; | ||
| - | cout << "The int square root of 5 is: " << (int)sqrt(INT_FIVE) << endl; | ||
| - | return 0; | ||
| - | } | ||
| - | </code> | ||