C++ lühikursus 1: Difference between revisions
From ICO wiki
Jump to navigationJump to search
Line 7: | Line 7: | ||
#define VASTUS 42 | #define VASTUS 42 | ||
#define Kala (x) (y) ((x)>(y) : "Suurem kala on X", "Suurem kala on Y") | #define Kala (x) (y) ((x)>(y) : "Suurem kala on X", "Suurem kala on Y") | ||
#ifdef WINDOWS | |||
#warning "Windows warning" | |||
#elif defined(linux) | |||
cout << "Fine operating system found" << endl; | |||
#else | |||
#error "Not supported OS" | |||
#endif | |||
</source> | </source> | ||
[http://en.wikipedia.org/wiki/C_preprocessor http://en.wikipedia.org/wiki/C_preprocessor] | |||
=Andmetüübid= | =Andmetüübid= |
Revision as of 09:31, 4 April 2010
Eelprotsessori korraldused
#include <iostream>
#include "kala.h"
#define VASTUS 42
#define Kala (x) (y) ((x)>(y) : "Suurem kala on X", "Suurem kala on Y")
#ifdef WINDOWS
#warning "Windows warning"
#elif defined(linux)
cout << "Fine operating system found" << endl;
#else
#error "Not supported OS"
#endif
http://en.wikipedia.org/wiki/C_preprocessor
Andmetüübid
Muutujad
tüüp muutuja [= väärtus];
int i = 0;
unsigned int a = 0;
char u = 's';
float s;
double b;
- Muutujatele eraldatakse mälu nende deklareerimisel
- Muutujal on tüüp
- Muutujal on skoop, ehk kehtivuspiirkond, kus muutujat saab kasutada
Skoop
Lingid
http://www.cplusplus.com/doc/tutorial/variables/ - Kohustuslik kirjandus