// This is a simple test program that demonstrates the use // of "SI_units.h". #include "SI_units.h" #define PUT( X ) cout << (X) << "\n" void main() { SI_length x = meter( 10 ); SI_area y = meter2( 5 ); SI_force z = newton( 3.4 ); SI_power power = watt(1); SI_radiance inten = watts_per_m2sr(1); SI_area area = inch(1) * centimeter(3); SI_time Time = 1.0 / hertz(500); SI_radiance Rad = watt(3.0) / ( inch(1) * inch(1) * steradian(1) ); SI_lum_energy L1 = talbot(111); SI_lum_energy L2 = lumen(111) * second(1);; SI_length Dist = foot( 1.0 ); inten = watt(1.2) / ( meter2(2) * steradian(0.004) ); area = 2.0; PUT( x *= 3.4 ); PUT( y ); PUT( x * x ); PUT( y * x ); PUT( z ); PUT( 1.0 / second(4) ); PUT( candela(1.0) / candela(4) ); PUT( candela(1.0) + candela(4) ); PUT( meter(1) - inch(1) ); PUT( watt(10.0) * second(3.0) ); PUT( watt(1.2) / ( meter2(2) * steradian(1) ) ); PUT( inten ); PUT( watt(1.2) / ( area * steradian(1) ) ); PUT( watt(1.2) / area ); PUT( (erg(234) / second(1)) / area ); PUT( ( watt(1.2) / area ) / steradian(1) ); PUT( 7 * steradian(2.0) / 4.0 ); PUT( watt(3.2) > watt(1.0) ); PUT( Dist ); // Make sure we haven't added any extra storage... SI_force Array1[ 100 ]; float Array2[ 100 ]; cout << "Storage = " << sizeof(Array1) << " and " << sizeof(Array2) << "\n"; // The following examples are WRONG and cause the compiler to complain. // watt(3.0) >= radian(2.0); // inten += candela(5); // SI_solid_angle omega = meter(1); // SI_power P = watt(4) * second(2); // SI_lum_flux F = lumen(111) * second(1);; }