Consts and Fields

const

存在于metadata, JIT 直接把值放入IL


如果另外一个assembly需要在执行时得到const的值,需要使用readonly的字段。


volatile

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1、Experiment purpose (1)Write the txt file. (2)Class definition. (3)Function application. (4)Selections. (5)Loops 2、Experiment task Project 1: Define the Rectangle2D class that contains: Two double data fields named x and y that specify the center of the rectangle with constant get functions and set functions. (Assume that the rectangle sides are parallel to x- or y-axes.) The double data fields width and height with constant get functions and set functions. A no-arg constructor that creates a default rectangle with (0, 0) for (x, y) and 1 for both width and height. A constructor that creates a rectangle with the specified x, y, width, and height. A constant function getArea() that returns the area of the rectangle. A constant function getPerimeter() that returns the perimeter of the rectangle. A constant function contains(double x, double y) that returns true if the specified point (x, y) is inside this rectangle. See Figure a. A constant function contains(const Rectangle2D &r) that returns true if the specified rectangle is inside this rectangle. See Figure b. A constant function overlaps(const Rectangle2D &r) that returns true if the specified rectangle overlaps with this rectangle. See Figure c. Draw the UML for the class. Implement the class. Write a test program that creates three Rectangle2D objects r1(2, 2, 5.5, 4.9), r2(4, 5, 10.5, 3.2)), and r3(3, 5, 2.3, 5.4), and displays r1’s area and perimeter, and displays the result of r1.contains(3, 3), r1.contains(r2), and r1.overlaps(r3). And save all these results in the txt file that is called Result.txt.写一段c++代码
06-06

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值