pointer_size คืออะไรครับ ใครอธิบายได้บ้าง
Printable View
pointer_size คืออะไรครับ ใครอธิบายได้บ้าง
ย้ายไปห้อง C/C++ พร้อมกับเพิ่มแต้มการทำผิดให้ init จำนวน 1 แต้ม คราวหน้าระวังด้วยนะครับ
ถ้า ถามเปน size แบบ array size ก้
pointer size ก้จะ ประมาณเท่ากับ memory ของ register ครับ เต็มเมื่อไหร่ก้จบ
ขนาดขึ้นกับเครื่องคอมครับ
พึ้นๆ ก้มีสัก... 4096 นะครับ สำหรับ คอมพิวเตอพื้นฐาน (อันนี้ไม่แน่ใจ)
ถ้าถามแบบ ขนาด ของ เม้าส ที่ใช้กันก้ 32*32 ครับ http://citec.us/forum/style_images/subblac...icons/icon6.gif
ขึ้นอยู่กับ Word size ของ CPU เป็นหลัก ว่ามีขนาดกี่ bit
เสริมให้อีกนิด...Quote:
ขึ้นอยู่กับ Word size ของ CPU เป็นหลัก ว่ามีขนาดกี่ bit
[/b]
และมันก็ขึ้นอยู่กับว่า pointer นั้นเป็น pointer แบบไหน (int pointer, char pointer ...)
ส่วน int, char จะมีขนานเท่าไหรนั้น ลองไปหาอ่านต่อนะครับ :-)
ขนาดของ Pointer ไม่ได้ขึ้นอยู่กับว่า Pointer นั้นชี้ไปที่ข้อมูลไหน แต่ขึ้นกับ word size (ตอน Compile)Quote:
เสริมให้อีกนิด...
และมันก็ขึ้นอยู่กับว่า pointer นั้นเป็น pointer แบบไหน (int pointer, char pointer ...)
ส่วน int, char จะมีขนานเท่าไหรนั้น ลองไปหาอ่านต่อนะครับ :-)
[/b]
สมัยนี้คงไม่มี pointer แบบ near กับ far แล้ว ถ้าเป็นสมัยก่อนนู้น pointer แต่ละตัวจะมีขนาดไม่เท่ากัน ขึ้นอยู่กับว่าอ้าง address ที่ไหน
ตอนนี้จะมียกเว้นแต่ Pointer to Members ซึ่งขึ้นอยู่กับ Compiler ว่าจะ ใช้ขนาดเท่าไหร่ แต่อย่างน้อยก็มากกว่าหรือเท่ากับขนาดของ Word size
Quote:
ขนาดของ Pointer ไม่ได้ขึ้นอยู่กับว่า Pointer นั้นชี้ไปที่ข้อมูลไหน แต่ขึ้นกับ word size (ตอน Compile)
สมัยนี้คงไม่มี pointer แบบ near กับ far แล้ว ถ้าเป็นสมัยก่อนนู้น pointer แต่ละตัวจะมีขนาดไม่เท่ากัน ขึ้นอยู่กับว่าอ้าง address ที่ไหน
ตอนนี้จะมียกเว้นแต่ Pointer to Members ซึ่งขึ้นอยู่กับ Compiler ว่าจะ ใช้ขนาดเท่าไหร่ แต่อย่างน้อยก็มากกว่าหรือเท่ากับขนาดของ Word size
[/b]
:-) โทษทีครับ ผมเข้าใจผิด คิดว่าเป็นขนาดของ pointer เวลาเขียนโปรแกรม เหมือนตอนที่เราใช้ฟังก์ชัน sizeof()
เหมือนตัวอย่างเล็ก ๆ นี้
[code]#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
อ้างอิงจากของท่าน pspn.n
[code]#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
โอ้กระจ่างเลยครับ ขอบคุณเอ็ดคุงมากครับ อิอิ จริง ๆ ผมชอบบรรยากาศแบบนี้แหละQuote:
ซึ่งผลลัพธ์จะออกมาเท่ากับ 4 เสมอ ( 32 bit = 4 ไบต์ )
[/b]
"บรรยากาศ แลกเปลี่ยนเรียนรู้"
Pointer to member เป็น Pointer อีกแบบหนึ่งที่ชี้ไปที่ member variable หรือ member function ของ class
ไม่ค่อยจะเจอในวิธีการเขียนโปรแกรมโดยทั่วไป เพราะต้องใช้ความเข้าใจพอสมควรและ debug ยาก ไม่แนะนำให้ใช้ ถ้าไม่จำเป็นจริงๆ (เคยใช้ราวๆสองครั้ง ตั้งแต่เคยเขียนโปรแกรมมา)
#pragma pointers_to_members(pointer-declaration, [most-general-representation] )
Specifies whether a pointer to a class member can be declared before its associated class definition and is used to control the pointer size and the code required to interpret the pointer. You can place a pointers_to_members pragma in your source file as an alternative to using the /vmx compiler options.
The pointer-declaration argument specifies whether you have declared a pointer to a member before or after the associated function definition. The pointer-declaration argument is one of the following two symbols:
Argument
full_generality Generates safe, sometimes nonoptimal code. You use full_generality if any pointer to a member is declared before the associated class definition. This argument always uses the pointer representation specified by the most-general-representation argument. Equivalent to /vmg.
best_case Generates safe, optimal code using best-case representation for all pointers to members. Requires defining the class before declaring a pointer to a member of the class. The default is best_case.
The most-general-representation argument specifies the smallest pointer representation that the compiler can safely use to reference any pointer to a member of a class in a translation unit. The argument can be one of the following:
single_inheritance The most general representation is single-inheritance, pointer to a member function. Causes an error if the inheritance model of a class definition for which a pointer to a member is declared is ever either multiple or virtual.
multiple_inheritance The most general representation is multiple-inheritance, pointer to a member function. Causes an error if the inheritance model of a class definition for which a pointer to a member is declared is virtual.
virtual_inheritance The most general representation is virtual-inheritance, pointer to a member function. Never causes an error. This is the default argument when #pragma pointers_to_members(full_generality) is used.
Refer: MSDN Oct2001