#include <iostream.h> int main() { cout << "Hello, world!\n"; } |
宣言のみ | 宣言及び定義 |
extern char ch; extern string s; extern int count extern const double pi; extern int error_number; extern char* name; extern char* season[]; struct Date; int day(Date* p); double sqrt (double); template なし struct User; enum Beer; なし |
char ch; string s; int count; const double pi = 3.14; int error_number; char* name = "Njal"; char* season[] = {"spring","" /*...*/}; struct Date {/*...*/}; int day(Date* p){/*...*/ return 0;} double sqrt (double){/*...*/ return 0;} template typedef complex struct User {/*...*/}; enum Beer {Carlsberg,Tuborg,Thor}; namespace NS {int a;} |
#include <iostream> using namespace std; enum Test {X,Y,Z}; int main() { cout << sizeof (char) << endl; cout << sizeof (int) << endl; cout << sizeof (long double) << endl; cout << sizeof (__int64) << endl; cout << sizeof (char*) << endl; cout << sizeof (__int64*) << endl; cout << sizeof (Test) << endl; } |
#include <cstdio> int main() { for (int i=0x20;i<0x7f;++i) printf("%3d [%c] %2x %s",i,i,i,(i+5)%6?"":"\n"); printf("\n"); } |
#include <cstdio> #include <limits> using namespace std; #define PRINTLIMITI(S,T) printf("%14s : min %12d max %12u\n",S, \ numeric_limits<T>::min(),numeric_limits<T>::max()) #define PRINTLIMITD(S,T) printf("%14s : min %11g max %12g\n",S, \ numeric_limits<T>::min(),numeric_limits<T>::max()) int main() { PRINTLIMITI("char",char); PRINTLIMITI("short",short); PRINTLIMITI("int",int); PRINTLIMITI("long",long); PRINTLIMITD("float",float); PRINTLIMITD("double",double); PRINTLIMITD("long double",long double); PRINTLIMITI("unsigned char",unsigned char); PRINTLIMITI("unsigned short",unsigned short); PRINTLIMITI("unsigned int",unsigned int); PRINTLIMITI("unsigned long",unsigned long); } |