⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arrays-usertype.texi

📁 A C++ class library for scientific computing
💻 TEXI
字号:
@node Array usertype@section Creating arrays of a user type@cindex Array of your own typesYou can use the @code{Array} class with types you have created yourself, ortypes from another library.  If you want to do arithmetic on the array,whatever operators you use on the arrays have to be defined on theunderlying type.For example, here's a simple class for doing fixed point computations in theinterval [0,1]:@smallexample@include examples/fixed-point.texi@end smallexampleThe function @code{huge(T)} returns the largest representable value for typeT; in the example above, it's equal to @code{UINT_MAX}.The @code{FixedPoint} class declares three useful operations: conversionfrom @code{double}, addition, and outputing to an @code{ostream}.  We canuse all of these operations on an @code{Array<FixedPoint>} object:@smallexample@include examples/fixed.texi@end smallexampleNote that the array @code{A} is initialized using a comma-delimited list of@code{double}; this makes use of the constructor @code{FixedPoint(double)}.The assignment @code{B = A + 0.05} uses@code{FixedPoint::operator+(FixedPoint)}, with an implicit conversion from@code{double} to @code{FixedPoint}.  Formatting the array @code{B} onto thestandard output stream is done using the output operator defined for@code{FixedPoint}.Here's the program output:@smallexample@include examples/fixed.out@end smallexample

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -