正在加载图片...
Class Definitions AC++ class consists of data members and methods(member functions) class Intcell Initializer list used to initialize the data Avoid implicit type conversion members directly public explicit Intcell( int initialvalye=0) storedvalue( initialvalue y[] Member functions int read( )const return storedValue iNdicates that the member's invocation does void write( int x) not change any of the data members storedvalue private int storedvalue Data member(s)10 Class Definitions ◼ A C++ class consists of data members and methods (member functions). class IntCell { public: explicit IntCell( int initialValue = 0 ) : storedValue( initialValue ) {} int read( ) const { return storedValue;} void write( int x ) { storedValue = x; } private: int storedValue; } Member functions Data member(s) Indicates that the member’s invocation does not change any of the data members. Avoid implicit type conversion Initializer list: used to initialize the data members directly
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有