fork download
  1. /*
  2. ===========================
  3.  Boring Introductory Stuff
  4. ===========================
  5. */
  6. #define _DIMENSIONS_H_
  7.  
  8. #include <vector>
  9. #include <string>
  10. #include <sstream>
  11. #include <cmath>
  12. #include <algorithm>
  13.  
  14. #ifndef tstring
  15. #ifdef _UNICODE
  16. typedef std::wstring tstring;
  17. typedef std::wistringstream tistringstream;
  18. typedef std::wostringstream tostringstream;
  19. typedef std::wostream tostream;
  20. typedef std::wistream tistream;
  21. #else
  22. typedef std::string tstring;
  23. typedef std::istringstream tistringstream;
  24. typedef std::ostringstream tostringstream;
  25. typedef std::ostream tostream;
  26. typedef std::istream tistream;
  27. #endif // _UNICODE
  28. #endif // tstring
  29.  
  30. //Some useful typedefs from the Windows SDK.
  31. //Since these are defined in WinNT.h, I'll take the chance of using this condition:
  32. #if !(defined(_WINNT_) || defined(_TSTR_DEFINED_))
  33. #define _TSTR_DEFINED_
  34.  
  35. #ifdef _UNICODE
  36.  
  37. typedef wchar_t TCHAR;
  38.  
  39. #else
  40.  
  41. typedef char THCAR;
  42.  
  43. #endif // _UNICODE
  44.  
  45. typedef TCHAR *LPTSTR;
  46. typedef TCHAR const *LPCTSTR;
  47.  
  48. #endif // !(defined(_WINNT_) || defined(_TSTR_DEFINED_))
  49.  
  50. //If tchar.h has been included, the following is defined already.
  51. #ifndef _T
  52. #ifdef _UNICODE
  53.  
  54. #define __T(x) L##x
  55.  
  56. #else
  57.  
  58. #define __T(x) x
  59.  
  60. #endif // _UNICODE
  61.  
  62. #define _T(x) __T(x)
  63.  
  64. #endif // _T
  65.  
  66. #ifndef NULL
  67. #define NULL 0
  68. #endif // NULL
  69. /*
  70. ===============================
  71.  END Boring Introductory Stuff
  72. ===============================
  73. */
  74.  
  75. #define LIBNS Units
  76.  
  77. namespace LIBNS
  78. {
  79. /*
  80. ===============
  81. Basic Classes
  82. ===============
  83. */
  84.  
  85. class FactorBase
  86. {
  87. //Constructors, Destructor
  88. protected:
  89. FactorBase()
  90. { }
  91. virtual ~FactorBase()
  92. { }
  93.  
  94. //Public Interface
  95. public:
  96. virtual double GetFactor() const { return 1; }
  97. virtual LPCTSTR GetName() const { return NULL; }
  98. virtual LPCTSTR GetSymbol() const { return NULL; }
  99. };
  100.  
  101. class Prefix : public FactorBase
  102. {
  103. //Member Data
  104. private:
  105. double m_convFactor;
  106. tstring m_name;
  107. tstring m_symbol;
  108.  
  109. //Constructors
  110. private:
  111. Prefix(Prefix const&); //No copying.
  112. Prefix(double convFactor = 1.0, LPCTSTR name = _T(""), LPCTSTR symbol = _T(""))
  113. : m_convFactor(convFactor), m_name(name), m_symbol(symbol), FactorBase()
  114. { }
  115.  
  116. //Public Interface
  117. public:
  118. virtual double GetFactor() const { return m_convFactor; }
  119. virtual LPCTSTR GetName() const { return m_name.c_str(); }
  120. virtual LPCTSTR GetSymbol() const { return m_symbol.c_str(); }
  121.  
  122. //Operators
  123. private:
  124. const Prefix& operator=(Prefix const&); //No assignment.
  125.  
  126. //Static Members
  127. public:
  128. static Prefix const NoPrefix;
  129.  
  130. static Prefix const Deca;
  131. static Prefix const Hecto;
  132. static Prefix const Kilo;
  133. static Prefix const Mega;
  134. static Prefix const Giga;
  135.  
  136. static Prefix const deci;
  137. static Prefix const centi;
  138. static Prefix const milli;
  139. static Prefix const micro;
  140. static Prefix const nano;
  141. };
  142.  
  143. Prefix const Prefix::NoPrefix = Prefix();
  144. Prefix const Prefix::Deca(10, _T("Deca"), _T("D"));
  145. Prefix const Prefix::Hecto(100, _T("Hecto"), _T("H"));
  146. Prefix const Prefix::Kilo(1000, _T("Kilo"), _T("k"));
  147. Prefix const Prefix::Mega(1000000, _T("Mega"), _T("M"));
  148. Prefix const Prefix::Giga(1e9, _T("Giga"), _T("G"));
  149.  
  150. Prefix const Prefix::deci(0.1, _T("deci"), _T("d"));
  151. Prefix const Prefix::centi(0.01, _T("centi"), _T("c"));
  152. Prefix const Prefix::milli(0.001, _T("milli"), _T("m"));
  153. Prefix const Prefix::micro(0.000001, _T("micro"), _T("u"));
  154. Prefix const Prefix::nano(1e-9, _T("nano"), _T("n"));
  155.  
  156. class Unit : public FactorBase
  157. {
  158. protected:
  159. Prefix const *m_prefix;
  160. //Buffer to hold the symbol so the return value of GetSymbol() can be LPCTSTR.
  161. mutable tstring _symbol;
  162.  
  163. //Constructors
  164. protected:
  165. Unit(Prefix const &prefix = Prefix::NoPrefix) : m_prefix(&prefix)
  166. { }
  167. Unit(Unit const &src) : m_prefix(src.m_prefix)
  168. { }
  169.  
  170. //Helpers
  171. protected:
  172. virtual LPCTSTR GetSymbolNoPrefix() const { return _T(""); }
  173.  
  174. //Public Interface
  175. public:
  176. virtual Unit* Clone() const { return NULL; }
  177. virtual double GetFactor() const { return m_prefix->GetFactor(); }
  178. virtual bool IsStandardUnit() const { return false; }
  179. virtual bool HasPrefixAffinity() const { return true; }
  180. virtual double GetFactorNoPrefix() const { return GetFactor() / m_prefix->GetFactor(); }
  181. virtual LPCTSTR GetSymbol() const
  182. {
  183. if (!_symbol.size())
  184. {
  185. _symbol = tstring(m_prefix->GetSymbol()) + GetSymbolNoPrefix();
  186. }
  187. return _symbol.c_str();
  188. }
  189.  
  190. //Operators
  191. public:
  192. Unit& operator=(Unit const &op2)
  193. {
  194. m_prefix = op2.m_prefix;
  195. _symbol.clear();
  196. return *this;
  197. }
  198.  
  199. //Dimensionless singleton
  200. public:
  201. static const Unit Dimensionless;
  202. };
  203.  
  204. const Unit Unit::Dimensionless = Unit();
  205.  
  206. class UnitContext
  207. {
  208. //Member data.
  209. private:
  210. double m_exponent;
  211. Unit *m_unit;
  212.  
  213. //Constructors
  214. public:
  215. UnitContext(UnitContext const &src) : m_exponent(src.m_exponent), m_unit(src.m_unit)
  216. { }
  217. UnitContext(Unit const &unit, double exponent) : m_exponent(exponent), m_unit(const_cast<Unit*>(&unit))
  218. { }
  219.  
  220. //Public Interface
  221. public:
  222. double GetExponent() const { return m_exponent; }
  223. void SetExponent(double newExponent) { m_exponent = newExponent; }
  224. Unit const& GetUnit() const { return *m_unit; }
  225.  
  226. UnitContext& operator=(UnitContext const &op2)
  227. {
  228. m_exponent = op2.m_exponent;
  229. m_unit = op2.m_unit;
  230. return *this;
  231. }
  232. };
  233.  
  234. class CompoundUnit : public Unit
  235. {
  236. //Internal data.
  237. protected:
  238. std::vector<UnitContext> _units;
  239.  
  240. //Constructors
  241. public:
  242. CompoundUnit() : Unit()
  243. { }
  244.  
  245. //Private functor to calculate the accumulated conversion factor.
  246. private:
  247. class _ConvFactorF
  248. {
  249. //Internal Data
  250. private:
  251. double _accumFactor;
  252.  
  253. //Constructor
  254. public:
  255. _ConvFactorF(double initialValue = 1.0) : _accumFactor(initialValue)
  256. { }
  257.  
  258. //Public Interface
  259. public:
  260. double GetAccumulatedConversionFactor() { return _accumFactor; }
  261.  
  262. //Operator overloads
  263. void operator()(UnitContext const &uc)
  264. {
  265. _accumFactor *= pow(uc.GetUnit().GetFactor(), uc.GetExponent());
  266. }
  267. };
  268.  
  269. //Private functor to derivate the symbol of the compound unit.
  270. private:
  271. class _SymbolAssemblerF
  272. {
  273. //Internal Data
  274. private:
  275. tostringstream _num_os;
  276. tostringstream _den_os;
  277. bool _useExponentChar;
  278.  
  279. //Constructors
  280. public:
  281. _SymbolAssemblerF(_SymbolAssemblerF const &src) //Copy constructor needed because the stupid for_each() will clone this.
  282. : _num_os(src._num_os.str())
  283. , _den_os(src._den_os.str())
  284. , _useExponentChar(src._useExponentChar)
  285. { }
  286. _SymbolAssemblerF(bool useExponentChar = false) : _useExponentChar(useExponentChar)
  287. { }
  288.  
  289. //Public Interface
  290. public:
  291. tstring GetAccummulatedSymbol()
  292. {
  293. tstring symbol = _num_os.str();
  294. tstring den = _den_os.str();
  295. if (den.size())
  296. {
  297. symbol += _T('/');
  298. symbol += den;
  299. }
  300. return symbol;
  301. //return tstring(_T("Nothing"));
  302. }
  303.  
  304. //Operator Overloads
  305. void operator()(UnitContext const &uc)
  306. {
  307. tostringstream &s = uc.GetExponent() < 0 ? _den_os : _num_os;
  308. s << uc.GetUnit().GetSymbol();
  309. if (abs(uc.GetExponent()) != 1)
  310. {
  311. if (_useExponentChar) s << _T('^');
  312. s << abs(uc.GetExponent());
  313. }
  314. }
  315. };
  316.  
  317. //Helpers
  318. protected:
  319. virtual Unit* Clone() const { return new CompoundUnit(); }
  320.  
  321. //Public Interface
  322. public:
  323. double GetFactor() const
  324. {
  325. _ConvFactorF f = std::for_each(_units.begin(), _units.end(), _ConvFactorF());
  326. return f.GetAccumulatedConversionFactor();
  327. }
  328. LPCTSTR GetSymbol() const
  329. {
  330. _SymbolAssemblerF f = std::for_each(_units.begin(), _units.end(), _SymbolAssemblerF());
  331. return f.GetAccummulatedSymbol().c_str();
  332. }
  333. };
  334.  
  335. /*
  336. ===================
  337. END Basic Classes
  338. ===================
  339. */
  340.  
  341. /*
  342. ==============
  343. Length Units
  344. ==============
  345. */
  346.  
  347. //Forward declaration of Length for friend purposes.
  348. class Length;
  349.  
  350. class LengthUnit : public Unit
  351. {
  352. friend class Length;
  353. //Constructors
  354. protected:
  355. LengthUnit() : Unit()
  356. { }
  357.  
  358. //Static Members
  359. public:
  360. static const LengthUnit &StandardUnit;
  361. };
  362.  
  363. class MeterUnit : public LengthUnit
  364. {
  365. //Constructors
  366. public:
  367. MeterUnit() : LengthUnit()
  368. { }
  369.  
  370. //Helpers
  371. protected:
  372. virtual LPCTSTR GetSymbolNoPrefix() const { return _T("m"); }
  373. virtual Unit* Clone() const { return new MeterUnit(); }
  374. //Public Interface.
  375. public:
  376. virtual bool IsStandardUnit() const { return true; }
  377. virtual LPCTSTR GetName() const { return _T("meter"); }
  378.  
  379. static const MeterUnit Meter;
  380. };
  381.  
  382. const MeterUnit MeterUnit::Meter = MeterUnit();
  383. const LengthUnit &LengthUnit::StandardUnit = MeterUnit::Meter;
  384.  
  385. class FootUnit : public LengthUnit
  386. {
  387. //Constructors
  388. public:
  389. FootUnit() : LengthUnit()
  390. { }
  391.  
  392. //Helpers
  393. protected:
  394. virtual LPCTSTR GetSymbolNoPrefix() const { return _T("ft"); }
  395. virtual Unit* Clone() const { return new FootUnit(); }
  396.  
  397. //Public Interface
  398. public:
  399. virtual double GetFactor() const { return 0.3048; }
  400. virtual LPCTSTR GetName() const { return _T("foot"); }
  401.  
  402. //Singleton
  403. public:
  404. static const FootUnit Foot;
  405. };
  406.  
  407. const FootUnit FootUnit::Foot = FootUnit();
  408.  
  409. /*
  410. ====================
  411. END Length Units
  412. ====================
  413. */
  414.  
  415. /*
  416. ============
  417. Time Units
  418. ============
  419. */
  420.  
  421. //Forward declaration of Time for friends purposes.
  422. class Time;
  423.  
  424. class TimeUnit : public Unit
  425. {
  426. friend class Time;
  427. //Constructors
  428. protected:
  429. TimeUnit() : Unit()
  430. { }
  431.  
  432. //Static Members
  433. public:
  434. static TimeUnit const &StandardUnit;
  435. };
  436.  
  437. class SecondUnit : public TimeUnit
  438. {
  439. //Constructors
  440. private:
  441. SecondUnit() : TimeUnit()
  442. { }
  443.  
  444. //Helpers
  445. protected:
  446. virtual LPCTSTR GetSymbolNoPrefix() const { return _T("s"); }
  447. virtual Unit* Clone() const { return new SecondUnit(); }
  448.  
  449. //Public Interface
  450. public:
  451. virtual bool IsStandardUnit() const { return true; }
  452. virtual LPCTSTR GetName() const { return _T("second"); }
  453.  
  454. static const SecondUnit Second;
  455. };
  456.  
  457. const SecondUnit SecondUnit::Second = SecondUnit();
  458. const TimeUnit &TimeUnit::StandardUnit = SecondUnit::Second;
  459.  
  460. class HourUnit : public TimeUnit
  461. {
  462. //Constructors
  463. private:
  464. HourUnit() : TimeUnit()
  465. { }
  466.  
  467. //Helpers
  468. virtual LPCTSTR GetSymbolNoPrefix() const { return _T("h"); }
  469. virtual Unit* Clone() const { return new HourUnit(); }
  470.  
  471. //Public Interface
  472. public:
  473. virtual double GetFactor() const { return 3600; }
  474. virtual LPCTSTR GetName() const { return _T("hour"); }
  475.  
  476. //Singleton
  477. public:
  478. static HourUnit const Hour;
  479. };
  480.  
  481. const HourUnit HourUnit::Hour = HourUnit();
  482.  
  483. /*
  484. ================
  485. END Time Units
  486. ================
  487. */
  488.  
  489. /*
  490. =============
  491. Speed Units
  492. =============
  493. */
  494.  
  495. class SpeedUnit : public CompoundUnit
  496. {
  497. //Constructors
  498. public:
  499. SpeedUnit() : CompoundUnit()
  500. { }
  501.  
  502. public:
  503. static SpeedUnit const &StandardUnit;
  504. };
  505.  
  506. class MetersPerSecondUnit : public SpeedUnit
  507. {
  508. //Constructors
  509. private:
  510. MetersPerSecondUnit() : SpeedUnit()
  511. {
  512. _units.push_back(UnitContext(MeterUnit::Meter, 1));
  513. _units.push_back(UnitContext(SecondUnit::Second, -1));
  514. }
  515.  
  516. //Singleton
  517. public:
  518. static MetersPerSecondUnit const MetersPerSecond;
  519. };
  520.  
  521. const MetersPerSecondUnit MetersPerSecondUnit::MetersPerSecond = MetersPerSecondUnit();
  522. const SpeedUnit &SpeedUnit::StandardUnit = MetersPerSecondUnit::MetersPerSecond;
  523.  
  524. class FeetPerSecondUnit : public SpeedUnit
  525. {
  526. //Constructors
  527. public:
  528. FeetPerSecondUnit() : SpeedUnit()
  529. {
  530. _units.push_back(UnitContext(FootUnit::Foot, 1));
  531. _units.push_back(UnitContext(SecondUnit::Second, -1));
  532. }
  533.  
  534. //Singleton
  535. public:
  536. static FeetPerSecondUnit const FeetPerSecond;
  537. };
  538.  
  539. const FeetPerSecondUnit FeetPerSecondUnit::FeetPerSecond = FeetPerSecondUnit();
  540.  
  541. /*
  542. =================
  543. END Speed Units
  544. =================
  545. */
  546.  
  547. /*
  548. ============
  549. Dimensions
  550. ============
  551. */
  552. template<class U>
  553. class Dimension
  554. {
  555. public:
  556. typedef U UnitType;
  557.  
  558. //Member data
  559. protected:
  560. double m_value;
  561. //Since I can't have by reference because I cannot convert to another unit
  562. //a pointer must be used. The actual object has to be maintained in the
  563. //subclass.
  564. //ConvertTo() calls the pure virtual function SaveUnit()
  565. UnitType *m_unit;
  566.  
  567. //Constructors
  568. protected:
  569. Dimension(double value, UnitType *unit)
  570. : m_value(value), m_unit(unit)
  571. { }
  572.  
  573. //Destructor
  574. public:
  575. ~Dimension()
  576. {
  577. DestroyUnit();
  578. }
  579.  
  580. //Helpers
  581. void DestroyUnit() { if (m_unit) delete m_unit; m_unit = NULL; }
  582. void AssignUnit(UnitType *newUnit) { DestroyUnit(); m_unit = newUnit; }
  583. double GetConversionFactor(UnitType const &newUnit) const
  584. {
  585. return m_unit->GetFactor() / newUnit.GetFactor();
  586. }
  587.  
  588. //Public Interface
  589. public:
  590. double GetValue() const { return m_value; }
  591. void SetValue(double newValue) { m_value = newValue; }
  592. UnitType const& GetUnit() const { return m_unit; }
  593. virtual void ConvertTo(UnitType const &newUnit)
  594. {
  595. m_value *= GetConversionFactor(newUnit);
  596. AssignUnit(dynamic_cast<UnitType*>(newUnit.Clone()));
  597. }
  598. //Á la .Net:
  599. virtual tstring ToString() const
  600. {
  601. tostringstream os;
  602. os << m_value << _T(" ") << m_unit->GetSymbol();
  603. return os.str();
  604. }
  605. virtual void ConvertToStandard()
  606. {
  607. ConvertTo(UnitType::StandardUnit);
  608. }
  609.  
  610. //Operators
  611. public:
  612. virtual bool operator<(Dimension const &op2) const
  613. {
  614. return (m_value * GetConversionFactor(UnitType::StandardUnit))
  615. < (op2.m_value * op2.GetConversionFactor(UnitType::StandardUnit));
  616. }
  617. virtual bool operator>(Dimension const &op2) const
  618. {
  619. return op2.operator <(*this);
  620. }
  621. virtual bool operator==(Dimension const &op2) const
  622. {
  623. return !(this->operator <(op2) || op2.operator <(*this));
  624. }
  625. };
  626.  
  627. template<class U>
  628. tostream& operator<<(tostream &op1, Dimension<U> const &op2)
  629. {
  630. return (op1 << op2.ToString());
  631. }
  632.  
  633. class Length : public Dimension<LengthUnit>
  634. {
  635. //Constructors
  636. public:
  637. Length() : Dimension<Length::UnitType>(0, dynamic_cast<Length::UnitType*>(Length::UnitType::StandardUnit.Clone()))
  638. { }
  639. Length(double value, Length::UnitType const &unit) : Dimension<Length::UnitType>(value, dynamic_cast<Length::UnitType*>(unit.Clone()))
  640. { }
  641. };
  642.  
  643. class Time : public Dimension<TimeUnit>
  644. {
  645. //Constructors
  646. public:
  647. Time() : Dimension<Time::UnitType>(0, dynamic_cast<Time::UnitType*>(Time::UnitType::StandardUnit.Clone()))
  648. { }
  649. Time(double value, Time::UnitType const &unit) : Dimension<Time::UnitType>(value, dynamic_cast<Time::UnitType*>(unit.Clone()))
  650. { }
  651. };
  652.  
  653. //class Speed : public Dimension<
  654. /*
  655. ================
  656. END Dimensions
  657. ================
  658. */
  659. }
  660.  
  661. /*
  662. ===========
  663.  Shortcuts
  664. ===========
  665. */
  666.  
  667. #ifndef NO_UNIT_SHORTCUTS
  668.  
  669. #define Meter LIBNS::MeterUnit::Meter
  670. #define Foot LIBNS::FootUnit::Foot
  671.  
  672. #endif // NO_UNIT_SHORTCUTS
  673.  
  674. #ifndef NO_PREFIX_SHORTCUTS
  675.  
  676. #define NoPrefix Prefix::NoPrefix
  677.  
  678. #define Deca LIBNS::Prefix::Deca
  679. #define Hecto LIBNS::Prefix::Hecto
  680. #define Kilo LIBNS::Prefix::Kilo
  681. #define Mega LIBNS::Prefix::Mega
  682. #define Giga LIBNS::Prefix::Giga
  683.  
  684. #define deci LIBNS::Prefix::deci
  685. #define centi LIBNS::Prefix::centi
  686. #define milli LIBNS::Prefix::milli
  687. #define micro LIBNS::Prefix::micro
  688. #define nano LIBNS::Prefix::nano
  689.  
  690. #endif // NO_PREFIX_SHORTCUTS
  691.  
  692. /*
  693. ===============
  694.  END Shortcuts
  695. ===============
  696. */
  697.  
  698. #include <iostream>
  699.  
  700. #ifdef _UNICODE
  701. #define tcout std::wcout
  702. #define tcin std::wcin
  703. #else
  704. #define tcout std::cout
  705. #define tcin std::cin
  706. #endif // _UNICODE
  707.  
  708. using std::endl;
  709.  
  710. int main()
  711. {
  712. Length myHeight(30.48, Meter);
  713. Length doorHeight(100, Foot);
  714. tcout << _T("I am ") << myHeight << _T(" tall.") << endl;
  715. tcout << _T("The doorway is ") << doorHeight << _T(" high.") << endl;
  716. myHeight.ConvertTo(Foot);
  717. doorHeight.ConvertTo(Meter);
  718. tcout << _T("I am ") << myHeight.ToString() << _T(" tall.") << endl;
  719. tcout << _T("The doorway is ") << doorHeight.ToString() << _T(" high.") << endl;
  720. if (myHeight > doorHeight)
  721. tcout << _T("You cannot enter the room! You are too tall. :-(") << endl;
  722. else if (myHeight < doorHeight)
  723. tcout << _T("You may enter the room. You are not that tall.") << endl;
  724. else
  725. tcout << _T("Hmmmm... try to enter the room at your own risk! Your height and the door's height are the same.") << endl;
  726. system("pause");
  727. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:45: error: expected initializer before ‘*’ token
prog.cpp:46: error: expected initializer before ‘const’
prog.cpp:97: error: ‘LPCTSTR’ does not name a type
prog.cpp:98: error: ‘LPCTSTR’ does not name a type
prog.cpp:112: error: ‘LPCTSTR’ has not been declared
prog.cpp:112: error: ‘LPCTSTR’ has not been declared
prog.cpp:119: error: ‘LPCTSTR’ does not name a type
prog.cpp:120: error: ‘LPCTSTR’ does not name a type
prog.cpp:112: error: default argument for parameter of type ‘int’ has type ‘const char [1]’
prog.cpp:112: error: default argument for parameter of type ‘int’ has type ‘const char [1]’
prog.cpp: In constructor ‘Units::Prefix::Prefix(double, int, int)’:
prog.cpp:107: warning: ‘Units::Prefix::m_symbol’ will be initialized after
prog.cpp:113: warning:   base ‘Units::FactorBase’
prog.cpp:112: warning:   when initialized here
prog.cpp:113: error: invalid conversion from ‘int’ to ‘const char*’
prog.cpp:113: error:   initializing argument 1 of ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]’
prog.cpp:113: error: invalid conversion from ‘int’ to ‘const char*’
prog.cpp:113: error:   initializing argument 1 of ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]’
prog.cpp: At global scope:
prog.cpp:144: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:144: error:   initializing argument 2 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:144: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:144: error:   initializing argument 3 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:145: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:145: error:   initializing argument 2 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:145: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:145: error:   initializing argument 3 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:146: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:146: error:   initializing argument 2 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:146: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:146: error:   initializing argument 3 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:147: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:147: error:   initializing argument 2 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:147: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:147: error:   initializing argument 3 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:148: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:148: error:   initializing argument 2 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:148: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:148: error:   initializing argument 3 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:150: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:150: error:   initializing argument 2 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:150: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:150: error:   initializing argument 3 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:151: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:151: error:   initializing argument 2 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:151: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:151: error:   initializing argument 3 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:152: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:152: error:   initializing argument 2 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:152: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:152: error:   initializing argument 3 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:153: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:153: error:   initializing argument 2 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:153: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:153: error:   initializing argument 3 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:154: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:154: error:   initializing argument 2 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:154: error: invalid conversion from ‘const char*’ to ‘int’
prog.cpp:154: error:   initializing argument 3 of ‘Units::Prefix::Prefix(double, int, int)’
prog.cpp:172: error: ‘LPCTSTR’ does not name a type
prog.cpp:181: error: ‘LPCTSTR’ does not name a type
prog.cpp:328: error: ‘LPCTSTR’ does not name a type
prog.cpp: In member function ‘void Units::CompoundUnit::_SymbolAssemblerF::operator()(const Units::UnitContext&)’:
prog.cpp:308: error: ‘const class Units::Unit’ has no member named ‘GetSymbol’
prog.cpp: At global scope:
prog.cpp:372: error: ‘LPCTSTR’ does not name a type
prog.cpp:377: error: ‘LPCTSTR’ does not name a type
prog.cpp:394: error: ‘LPCTSTR’ does not name a type
prog.cpp:400: error: ‘LPCTSTR’ does not name a type
prog.cpp:446: error: ‘LPCTSTR’ does not name a type
prog.cpp:452: error: ‘LPCTSTR’ does not name a type
prog.cpp:468: error: ‘LPCTSTR’ does not name a type
prog.cpp:474: error: ‘LPCTSTR’ does not name a type
prog.cpp: In function ‘int main()’:
prog.cpp:712: error: ‘Length’ was not declared in this scope
prog.cpp:712: error: expected `;' before ‘myHeight’
prog.cpp:713: error: expected `;' before ‘doorHeight’
prog.cpp:714: error: ‘myHeight’ was not declared in this scope
prog.cpp:715: error: ‘doorHeight’ was not declared in this scope
prog.cpp:726: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result
prog.cpp: In member function ‘tstring Units::Dimension<U>::ToString() const [with U = Units::TimeUnit]’:
prog.cpp:727:   instantiated from here
prog.cpp:602: error: ‘class Units::TimeUnit’ has no member named ‘GetSymbol’
prog.cpp: In member function ‘tstring Units::Dimension<U>::ToString() const [with U = Units::LengthUnit]’:
prog.cpp:727:   instantiated from here
prog.cpp:602: error: ‘class Units::LengthUnit’ has no member named ‘GetSymbol’
stdout
Standard output is empty