Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: เกี่ยวกับ pointer_size ใครทราบบ้าง

  1. #1
    Junior Member
    Join Date
    Mar 2008
    Posts
    0


    pointer_size คืออะไรครับ ใครอธิบายได้บ้าง

  2. #2
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    ย้ายไปห้อง C/C++ พร้อมกับเพิ่มแต้มการทำผิดให้ init จำนวน 1 แต้ม คราวหน้าระวังด้วยนะครับ

  3. #3


    Cool

    ถ้า ถามเปน size แบบ array size ก้
    pointer size ก้จะ ประมาณเท่ากับ memory ของ register ครับ เต็มเมื่อไหร่ก้จบ
    ขนาดขึ้นกับเครื่องคอมครับ
    พึ้นๆ ก้มีสัก... 4096 นะครับ สำหรับ คอมพิวเตอพื้นฐาน (อันนี้ไม่แน่ใจ)

    ถ้าถามแบบ ขนาด ของ เม้าส ที่ใช้กันก้ 32*32 ครับ http://citec.us/forum/style_images/subblac...icons/icon6.gif

  4. #4
    Senior Member
    Join Date
    Jul 2004
    Location
    Bangkok
    Posts
    187


    ขึ้นอยู่กับ Word size ของ CPU เป็นหลัก ว่ามีขนาดกี่ bit

  5. #5
    Senior Member
    Join Date
    Oct 2006
    Location
    thailand
    Posts
    182


    ขึ้นอยู่กับ Word size ของ CPU เป็นหลัก ว่ามีขนาดกี่ bit
    [/b]
    เสริมให้อีกนิด...

    และมันก็ขึ้นอยู่กับว่า pointer นั้นเป็น pointer แบบไหน (int pointer, char pointer ...)
    ส่วน int, char จะมีขนานเท่าไหรนั้น ลองไปหาอ่านต่อนะครับ :-)

  6. #6
    Senior Member
    Join Date
    Jul 2004
    Location
    Bangkok
    Posts
    187


    เสริมให้อีกนิด...

    และมันก็ขึ้นอยู่กับว่า pointer นั้นเป็น pointer แบบไหน (int pointer, char pointer ...)
    ส่วน int, char จะมีขนานเท่าไหรนั้น ลองไปหาอ่านต่อนะครับ :-)
    [/b]
    ขนาดของ Pointer ไม่ได้ขึ้นอยู่กับว่า Pointer นั้นชี้ไปที่ข้อมูลไหน แต่ขึ้นกับ word size (ตอน Compile)

    สมัยนี้คงไม่มี pointer แบบ near กับ far แล้ว ถ้าเป็นสมัยก่อนนู้น pointer แต่ละตัวจะมีขนาดไม่เท่ากัน ขึ้นอยู่กับว่าอ้าง address ที่ไหน

    ตอนนี้จะมียกเว้นแต่ Pointer to Members ซึ่งขึ้นอยู่กับ Compiler ว่าจะ ใช้ขนาดเท่าไหร่ แต่อย่างน้อยก็มากกว่าหรือเท่ากับขนาดของ Word size

  7. #7
    Senior Member
    Join Date
    Oct 2006
    Location
    thailand
    Posts
    182


    ขนาดของ 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[])
    {

  8. #8


    อ้างอิงจากของท่าน pspn.n
    [code]#include <cstdlib>
    #include <iostream>

    using namespace std;

    int main(int argc, char *argv[])
    {

  9. #9
    Senior Member
    Join Date
    Oct 2006
    Location
    thailand
    Posts
    182


    ซึ่งผลลัพธ์จะออกมาเท่ากับ 4 เสมอ ( 32 bit = 4 ไบต์ )
    [/b]
    โอ้กระจ่างเลยครับ ขอบคุณเอ็ดคุงมากครับ อิอิ จริง ๆ ผมชอบบรรยากาศแบบนี้แหละ

    "บรรยากาศ แลกเปลี่ยนเรียนรู้"

  10. #10
    Senior Member
    Join Date
    Jul 2004
    Location
    Bangkok
    Posts
    187


    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

Page 1 of 2 12 LastLast

Similar Threads

  1. เกี่ยวกับ cmd
    By son2007 in forum Linux, Unix , Window เกี่ยวกับ OS ต่างๆ
    Replies: 1
    Last Post: 04-11-2007, 05:54 PM
  2. e book เกี่ยวกับ SSL
    By HarO in forum World Hacking Ebook
    Replies: 0
    Last Post: 12-10-2007, 10:29 AM
  3. เกี่ยวกับ control
    By joooj in forum แจ้งปัญหาการใช้งานบอร์ด
    Replies: 1
    Last Post: 04-08-2007, 12:24 AM
  4. แจก e-book เกี่ยวกับ VB
    By choco2006 in forum E-Book, Video หรือบทความทั่วไปด้าน Computer
    Replies: 0
    Last Post: 11-07-2007, 01:46 PM
  5. E-book เกี่ยวกับ RE
    By online2004 in forum Hacking/Cracking's E-book
    Replies: 0
    Last Post: 27-03-2007, 11:19 AM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •