Note the position of the prototype for the ordinary function version o การแปล - Note the position of the prototype for the ordinary function version o ไทย วิธีการพูด

Note the position of the prototype

Note the position of the prototype for the ordinary function version of operator > () . It needs to follow
the class definition, because it refers to a CBox object in the parameter list. If you place it before the
class definition, the example will not compile.
There is a way to place it at the beginning of the program file following the #include statement: use an
incomplete class declaration . This would precede the prototype and would look like this:
class CBox; // Incomplete class declaration
bool operator > (const double & value, const CBox & aBox); // Function prototype
Operator Overloading
The incomplete class declaration identifies CBox to the compiler as a class and is sufficient to allow the
compiler to process the prototype for the function properly, since the compiler now knows that CBox is
a user - defined type to be specified later.
This mechanism is also essential in circumstances such as those where you have two classes, each of
which has a pointer to an object of the other class as a member. They will each require the other to
be declared first. It is only possible to resolve such an impasse through the use of an incomplete class
declaration.
The output from the example is:
Constructor called.
Constructor called.
mediumBox is bigger than smallBox
mediumBox capacity is more than 50
smallBox capacity is less than 10
Destructor called.
Destructor called.
After the constructor messages due to the declarations of the objects smallBox and mediumBox , you
have the output lines from the three if statements, each of which is working as you would expect. The
first of these calls the operator function that is a class member and works with two CBox objects.
The second calls the member function that has a parameter of type double . The expression in the
third if statement calls the operator function that you have implemented as an ordinary function.
As it happens, you could have made both the operator functions that are class members ordinary
functions, because they only need access to the member function Volume() , which is public
0/5000
จาก: -
เป็น: -
ผลลัพธ์ (ไทย) 1: [สำเนา]
คัดลอก!
Note the position of the prototype for the ordinary function version of operator > () . It needs to follow the class definition, because it refers to a CBox object in the parameter list. If you place it before the class definition, the example will not compile. There is a way to place it at the beginning of the program file following the #include statement: use an incomplete class declaration . This would precede the prototype and would look like this: class CBox; // Incomplete class declarationbool operator > (const double & value, const CBox & aBox); // Function prototype Operator Overloading The incomplete class declaration identifies CBox to the compiler as a class and is sufficient to allow the compiler to process the prototype for the function properly, since the compiler now knows that CBox is a user - defined type to be specified later. This mechanism is also essential in circumstances such as those where you have two classes, each of which has a pointer to an object of the other class as a member. They will each require the other to be declared first. It is only possible to resolve such an impasse through the use of an incomplete class declaration. The output from the example is: Constructor called.Constructor called.mediumBox is bigger than smallBoxmediumBox capacity is more than 50smallBox capacity is less than 10Destructor called.Destructor called. After the constructor messages due to the declarations of the objects smallBox and mediumBox , you have the output lines from the three if statements, each of which is working as you would expect. The first of these calls the operator function that is a class member and works with two CBox objects. The second calls the member function that has a parameter of type double . The expression in the third if statement calls the operator function that you have implemented as an ordinary function. As it happens, you could have made both the operator functions that are class members ordinary functions, because they only need access to the member function Volume() , which is public
การแปล กรุณารอสักครู่..
ผลลัพธ์ (ไทย) 2:[สำเนา]
คัดลอก!
หมายเหตุตำแหน่งของต้นแบบสำหรับรุ่นธรรมดาฟังก์ชั่นของผู้ประกอบการ> () จะต้องมีการปฏิบัติตาม
ข้อกำหนดของชั้นเพราะมันหมายถึงวัตถุ CBox ในรายการพารามิเตอร์ ถ้าคุณวางไว้ก่อนที่จะมี
การกำหนดระดับตัวอย่างจะไม่รวบรวม.
ไม่มีทางที่จะวางไว้ที่จุดเริ่มต้นของแฟ้มโปรแกรมดังต่อไปนี้คำสั่ง #include คือใช้
การประกาศคลาสที่ไม่สมบูรณ์ นี้จะนำต้นแบบและจะมีลักษณะเช่นนี้
ระดับ CBox; // ประกาศคลาสที่ไม่สมบูรณ์
ประกอบการบูล> (const คู่และค่า const CBox และ ABox); // ต้นแบบฟังก์ชั่น
มากไปดำเนินการ
ประกาศคลาสที่ไม่สมบูรณ์จะระบุ CBox คอมไพเลอร์เป็นชั้นและจะเพียงพอที่จะช่วยให้
คอมไพเลอร์ในการประมวลผลต้นแบบสำหรับการทำงานอย่างถูกต้องตั้งแต่คอมไพเลอร์ในขณะนี้รู้ว่า CBox เป็น
ผู้ใช้ - กำหนดประเภทที่จะระบุ ต่อมา.
กลไกนี้ยังเป็นสิ่งจำเป็นในสถานการณ์เช่นนั้นที่คุณมีสองชั้นแต่ละ
ที่มีตัวชี้ไปยังวัตถุของคลาสอื่น ๆ เป็นสมาชิก พวกเขาแต่ละคนจะต้องใช้อื่น ๆ ที่จะ
ได้รับการประกาศเป็นครั้งแรก มันจะเป็นไปได้ที่จะแก้ปัญหาดังกล่าวทางตันผ่านการใช้ระดับที่ไม่สมบูรณ์
. ประกาศ
เอาท์พุทจากตัวอย่างคือ:
. สร้างที่เรียกว่า
สร้างที่เรียกว่า.
mediumBox มีขนาดใหญ่กว่า smallBox
mediumBox ความจุมากกว่า 50
smallBox ความจุน้อยกว่า 10
เตาเผาที่เรียกว่า .
เตาเผาที่เรียกว่า.
หลังจากข้อความสร้างเนื่องจากการประกาศของวัตถุ smallBox และ mediumBox คุณ
มีสายออกจากสามถ้างบแต่ละที่มีการทำงานที่คุณคาดหวัง
แรกของสายเหล่านี้ฟังก์ชั่นผู้ประกอบการที่เป็นสมาชิกระดับและทำงานร่วมกับวัตถุสอง CBox.
ที่สองเรียกฟังก์ชันสมาชิกที่มีพารามิเตอร์ประเภทคู่ การแสดงออกใน
ที่สามถ้าคำสั่งเรียกฟังก์ชันประกอบการที่คุณได้นำมาใช้เป็นฟังก์ชั่นสามัญ.
ในฐานะที่มันเกิดขึ้นคุณจะได้ทำหน้าที่ทั้งผู้ประกอบการที่เป็นสมาชิกสามัญระดับ
ฟังก์ชั่นเพราะพวกเขาจะต้องเข้าถึงปริมาณฟังก์ชันสมาชิก ( ) ซึ่งเป็นที่สาธารณะ
การแปล กรุณารอสักครู่..
ผลลัพธ์ (ไทย) 3:[สำเนา]
คัดลอก!
ทราบตำแหน่งของต้นแบบเพื่อการทำงานของผู้ประกอบการ ( รุ่นธรรมดา ) มันต้องติดตาม
ชั้นเรียนความหมาย เพราะมันหมายถึง การ cbox วัตถุในรายการพารามิเตอร์ ถ้าคุณวางไว้ก่อน
ระดับความหมาย ตัวอย่างจะไม่รวบรวม .
มีวิธีการวางที่จุดเริ่มต้นของแฟ้มโปรแกรมต่อไปนี้#รวมถึงงบ : ใช้
สมบูรณ์ระดับประกาศ . นี้จะนำหน้าต้นแบบและจะมีลักษณะเช่นนี้ :
ชั้น cbox ; / / ไม่สมบูรณ์ประกาศ
ห้องบูลผู้ประกอบการ > ( ค่า& Const คู่ Const cbox & abox ) ; / / ฟังก์ชันต้นแบบ
-
ประกาศชั้นเรียนที่สมบูรณ์คือโหลด cbox ให้คอมไพเลอร์เป็นชั้น และเพียงพอที่จะให้
การแปล กรุณารอสักครู่..
 
ภาษาอื่น ๆ
การสนับสนุนเครื่องมือแปลภาษา: กรีก, กันนาดา, กาลิเชียน, คลิงออน, คอร์สิกา, คาซัค, คาตาลัน, คินยารวันดา, คีร์กิซ, คุชราต, จอร์เจีย, จีน, จีนดั้งเดิม, ชวา, ชิเชวา, ซามัว, ซีบัวโน, ซุนดา, ซูลู, ญี่ปุ่น, ดัตช์, ตรวจหาภาษา, ตุรกี, ทมิฬ, ทาจิก, ทาทาร์, นอร์เวย์, บอสเนีย, บัลแกเรีย, บาสก์, ปัญจาป, ฝรั่งเศส, พาชตู, ฟริเชียน, ฟินแลนด์, ฟิลิปปินส์, ภาษาอินโดนีเซี, มองโกเลีย, มัลทีส, มาซีโดเนีย, มาราฐี, มาลากาซี, มาลายาลัม, มาเลย์, ม้ง, ยิดดิช, ยูเครน, รัสเซีย, ละติน, ลักเซมเบิร์ก, ลัตเวีย, ลาว, ลิทัวเนีย, สวาฮิลี, สวีเดน, สิงหล, สินธี, สเปน, สโลวัก, สโลวีเนีย, อังกฤษ, อัมฮาริก, อาร์เซอร์ไบจัน, อาร์เมเนีย, อาหรับ, อิกโบ, อิตาลี, อุยกูร์, อุสเบกิสถาน, อูรดู, ฮังการี, ฮัวซา, ฮาวาย, ฮินดี, ฮีบรู, เกลิกสกอต, เกาหลี, เขมร, เคิร์ด, เช็ก, เซอร์เบียน, เซโซโท, เดนมาร์ก, เตลูกู, เติร์กเมน, เนปาล, เบงกอล, เบลารุส, เปอร์เซีย, เมารี, เมียนมา (พม่า), เยอรมัน, เวลส์, เวียดนาม, เอสเปอแรนโต, เอสโทเนีย, เฮติครีโอล, แอฟริกา, แอลเบเนีย, โคซา, โครเอเชีย, โชนา, โซมาลี, โปรตุเกส, โปแลนด์, โยรูบา, โรมาเนีย, โอเดีย (โอริยา), ไทย, ไอซ์แลนด์, ไอร์แลนด์, การแปลภาษา.

Copyright ©2025 I Love Translation. All reserved.

E-mail: