编程题.这个编程题我怎么连意思都读不懂?有明白的吗?

学习 时间:2026-04-07 23:32:40 阅读:3975
编程题.这个编程题我怎么连意思都读不懂?有明白的吗?编写一个正方形类Square,包含:一个protected属性:正方形的边长a.两个构造方法:(1)一个带有一个参数的构造方法,用于将a属性初始化;(2)一个不带参数的构造方法,将正方形初始化为边长为10.两个方法:(1)求正方形面积的方法area()(2)求正方形周长的方法perimeter()通过继承Square类编写一个具有确定位置的正方形类PlainSquare,其确定位置用正方形的左上角坐标来标识,包含:添加两个属性:正方形左上角坐标startX和startY.两个构造器方法:(1)带3个参数的构造方法,用于对startX、startY和a属性初始化;(2)不带参数的构造方法,将正方形初始化为左上角坐标、边长都为0的正方形;添加一个方法:判断某个点是否在正方形内部的方法isInside(double x,double y).如在正方形内,返回true,否则,返回false.提示:点在正方形内是指满足条件:x>=startX&&xstartY&&y

最佳回答

欢呼的冥王星

优美的彩虹

2026-04-07 23:32:40

这不是<<C++编程思想>>中的问题!
原问题是:(见《thinking in C++ 2nd》)
33。Repair the problem in Exercise 32 using technique one
shown in this book。
意思是修正练习32中的错误。32题是:
32。In a header file,create a class Mirror that contains two
data members:a pointer to a Mirror object and a bool。
Give it two constructors:the default constructor
initializes the bool to true and the Mirror pointer to zero。
The second constructor takes as an argument a pointer to
a Mirror object,which it assigns to the object’s internal
pointer; it sets the bool to false。Add a member function
test( ):if the object’s pointer is nonzero,it returns the
value of test( ) called through the pointer。If the pointer is
zero,it returns the bool。Now create five cpp files,each
of which includes the Mirror header。The first cpp file
defines a global Mirror object using the default
constructor。The second file declares the object in the first
file as extern,and defines a global Mirror object using
the second constructor,with a pointer to the first object。
Keep doing this until you reach the last file,which will
also contain a global object definition。In that file,main( )
should call the test( ) function and report the result。If the
result is true,find out how to change the linking order
for your linker and change it until the result is false。
我是在想不通你的题目从哪里来的。
32题的要求是:
If the result is true,find out how to change the linking order for your linker and change it until the result is false。
如果结果是真,找出如何为你的链接器改变(这些实现文件的)链接顺序,并且改变它(链接顺序)直到返回false。
这个问题的核心目的就是为了让你理
用extern声明一个变量,可以告诉编译器这个变量在别的地方已经实现过了,编译器在使用它之前应现查找它的实现。
如此以来程序就不会出现不可预知的错误了。
最后告诉你一个有价值的信息:几年前有人写过一个《给C++初学者的50点忠告》的帖子,上面有一条:“请看《thinking in C++》而不要看《C++变成死相》”。这就是说,《C++编程思想》这本书的翻译是超级垃圾的。我看过不少网友批评此书的翻译者太不负责,而由这道题目可见一般。
既然如此,你为什么还看它?

最新回答共有2条回答

  • 怕孤单的心情
    回复
    2026-04-07 23:32:40

    这不是<<C++编程思想>>中的问题!原问题是:(见《thinking in C++ 2nd》)33。Repair the problem in Exercise 32 using technique oneshown in this book。意思是修正练习32中的错误。32题是:32。In a header file,create a class Mirror that contains twodata members:a pointer to a Mirror object and a bool。Give it two constructors:the default constructorinitializes the bool to true and the Mirror pointer to zero。The second constructor takes as an argument a pointer toa Mirror object,which it assigns to the object’s internalpointer; it sets the bool to false。Add a member functiontest( ):if the object’s pointer is nonzero,it returns thevalue of test( ) called through the pointer。If the pointer iszero,it returns the bool。Now create five cpp files,eachof which includes the Mirror header。The first cpp filedefines a global Mirror object using the defaultconstructor。The second file declares the object in the firstfile as extern,and defines a global Mirror object usingthe second constructor,with a pointer to the first object。Keep doing this until you reach the last file,which willalso contain a global object definition。In that file,main( )should call the test( ) function and report the result。If theresult is true,find out how to change the linking orderfor your linker and change it until the result is false。我是在想不通你的题目从哪里来的。32题的要求是:If the result is true,find out how to change the linking order for your linker and change it until the result is false。如果结果是真,找出如何为你的链接器改变(这些实现文件的)链接顺序,并且改变它(链接顺序)直到返回false。这个问题的核心目的就是为了让你理用extern声明一个变量,可以告诉编译器这个变量在别的地方已经实现过了,编译器在使用它之前应现查找它的实现。如此以来程序就不会出现不可预知的错误了。最后告诉你一个有价值的信息:几年前有人写过一个《给C++初学者的50点忠告》的帖子,上面有一条:“请看《thinking in C++》而不要看《C++变成死相》”。这就是说,《C++编程思想》这本书的翻译是超级垃圾的。我看过不少网友批评此书的翻译者太不负责,而由这道题目可见一般。既然如此,你为什么还看它?

上一篇 荷兰为什么被称为运河之国?急

下一篇 关于阅览室的名言警句3个