c++ - How to refrain from CS2512 correctly -
Please help me with the following problem:
I have the following classes:
class chemical element {private: std :: string _name; Zero Init (const std :: string and name); Public: Chemical Element (Const Stroot :: String and Name); Chemical Element (Conic Chemical Element & CE); }; Class combination rule {private: chemical element _ c1; Chemical Element _ C2; Zero Init (const chemical allment and CE1, conic chemical element and CE2); Public: Combination Rule (Conic Chemical Element and CE1, Conic Chemical Element and C2); Combination rule (combination combination rule and rule); };
The implementation is clear I wanted to initialize the combination rule by using the init method to reduce the code repetition. Hi, if I do not use the "member initialization list" of each manufacturer, then the compiler "complains with the error C2512: 'Chemical Element: No proper default constructor is available". Is a default constructor or member a great way to solve this error instead of using the initial list? BTW: If there are any other problems in class definitions, please also add it. Since I'm reviewing C ++, I should know about them.
The combination rule
is because they are chemical element < / Code> CombineRule :: CombinationRule (Conic Chemical Element and CE1, Conic Chemical Element and C2): _ce1 (ce1), _C2 (CE2) {...} combination rules: : Combination rules (Const Combination rules and rules): _ce1 (rule._ce1), _ce2 (rule._ce2) {...}
Comments
Post a Comment