جميع الكتب

مهني

1 Markets I: The Ecosystem and Exchange-Traded Marketsالأسواق عبر الإنترنت 2 Markets II: Rates, FX and Creditالأسواق عبر الإنترنت 3 Markets III: Commodities, Energy and Cryptoالأسواق عبر الإنترنت 4 Quantitative Methodsالأساليب عبر الإنترنت 5 Derivatives and Volatilityالمشتقات عبر الإنترنت 6 Rates, Credit, XVA and Riskالفائدة والائتمان والمخاطر عبر الإنترنت 7 Research Craft: Predictors, Backtests, Measurement, Portfoliosالبحث عبر الإنترنت 8 Strategies I: Equities and Futuresالاستراتيجيات عبر الإنترنت 9 Strategies II: Volatility, Relative Value, Macro and the Bank Desksالاستراتيجيات عبر الإنترنت 10 Microstructure and Executionالتنفيذ عبر الإنترنت 11 Market Making and High-Frequency Tradingصناعة السوق عبر الإنترنت 12 Machine Learning for Marketsتعلم الآلة عبر الإنترنت 13 Low-Latency Softwareالتكنولوجيا عبر الإنترنت 14 Networks, Hardware and Trading Infrastructureالتكنولوجيا عبر الإنترنت 15 Research, Data and Risk Platformsالتكنولوجيا عبر الإنترنت 16 The Desk and the Firmالشركة عبر الإنترنت 17 The Industry: Firms, Roles and Careersالمسارات المهنية عبر الإنترنت 18 Interviews I: Maths, Probability and Speedالمسارات المهنية عبر الإنترنت 19 Interviews II: Markets, Trading Games and the Final Roundالمسارات المهنية عبر الإنترنت 20 Interviews III: Codeالمسارات المهنية عبر الإنترنت
التطبيقات حول المدرب تسجيل الدخول ابدأ القراءة

Computer Science · المسرد

ما معنى Class invariant؟

Definition 1.7 University Computer Science — Year 2 · الفصل 1 — From C to C++: Classes and Resource Management

A class invariant is a property of the data members that every constructor establishes and every public member function preserves. A constructor that cannot establish it does not return: it reports the failure (Section 1.4), and no object exists.

أمثلة

Example 1.8 (Building 6/(−8)6/(-8))

The initialiser list sets num_ = 6, den_ = -8. The body finds den_ nonzero and negative, so it negates both, −6/8-6/8, then divides both by gcd⁡(−6,8)=2\gcd(-6, 8) = 2 (std::gcd returns a non-negative result): −3/4-3/4. The sum a + b is built by the constructor too, from (−3)⋅4+1⋅4=−8(-3)\cdot 4 + 1 \cdot 4 = -8 over 1616, and comes out as −1/2-1/2. The expression a + 1 works because Fraction(long whole) is a constructor with one argument: the compiler uses it to convert 1 into 1/11/1. The defaulted operator== compares the members one by one, which is correct only because the invariant makes the representation unique.

اقرأ في الفصل →