IRiS nX
114 ARTICLES / 235 REPLIES [1:2]
=ADMIN=


#113. ¹Ù¶÷µ¹ÀÌ
struct ÀÇ ÇÔ¼ö Æ÷ÀÎÅÍ°¡ ±¸Á¶Ã¼ ÀÚ½ÅÀÇ ¸â¹ö¸¦ ÂüÁ¶ Çϱâ À§ÇÑ 2005/04/12 (Tue)

¾È³çÇϼ¼¿ä

typedef struct _test_struct {
int aaa;
void (*out)(int,int);
}TEST_STRUCT;

TEST_STRUCT test_struct = {
0xffff,test_out
};



ÀÌ·¯ÇÑ ±¸Á¶Ã¼°¡ ÀÖ´Ù°í ÇßÀ»¶§
ÇÔ¼öÆ÷ÀÎÅÍ void (*out)(int,int) Àº ¾Æ·¡ÀÇ ÇÔ¼ö¿Í ¿¬°áÀÌ µË´Ï´Ù.

void
test_out(int a,int b)
{
TEST_STRUCT *self = &test_struct;
printf("%d\r\n",self->aaa);
}



Á¦°¡ ±Ã±ÝÇÑ Á¡Àº ¹Ù·Î

TEST_STRUCT *self = &test_struct;

ÀÌ ºÎºÐ ÀÔ´Ï´Ù.
±¸Á¶Ã¼ ³»ÀÇ ÇÔ¼öÆ÷ÀÎÅÍ°¡ ÀÚ½ÅÀÇ ±¸Á¶Ã¼³»ÀÇ
±¸Á¶Ã¼ º¯¼ö¸¦ ¾ï¼¼½º ÇÏ´Â ¹æ¹ýÀ» ¾ï¼¼½º ÇÏ´Â ¹æ¹ýÀÔ´Ï´Ù.

¿¹¸¦ µé¸é C++ Ŭ·¡½ºÀÇ ¸â¹ö º¯¼ö¸¦ ¾ï¼¼½º Çϴ°Íó·³ C ·Î ±¸Çö Çϴ°ÍÀÔ´Ï´Ù. ±×·¯±â À§Çؼ­´Â Àú·¯ÇÑ ¹ø°Å·¯¿î °úÁ¤ÀÌ ¾ø¾úÀ¸¸é ÇÕ´Ï´Ù.
±¸Á¶Ã¼°¡ ¼±¾ð µÉ¶§¸¶´Ù ÇÔ¼ö Æ÷ÀÎÅÍÀÇ ±¸Çö ÇÔ¼ö´Â ÀÚµ¿À¸·Î
ÀÚ±â ÀÚ½ÅÀÌ ±¸ÇöµÈ ÀÇ ±¸Á¶Ã¼ º¯¼ö¸¦ ¾ï¼¼½º ÇÏ´Â ¹æ¹ýÀÌ ¾øÀ»±î¿ä?

¿ÀÁ÷ C·Î ±¸Çö ÇßÀ¸¸é Çϴµ¥.. Àß »ý°¢ÀÌ ¾È¶°¿À¸£³×¿ä.. ¿¡°ø.. OTL...

#113-1. ¿¤Áö¶¿·¹²Ä 2005/04/13 (Wed)
-_-;;
CÀÇ ½ºÆ®·°ÃÄ´Â 'µ¥ÀÌŸ¸ðÀ½' ±× ÀÌ»óµµ ±× ÀÌÇϵµ ¾Æ´Õ´Ï´Ù.
Á¤ °£´ÜÈ÷ ÇÏ·Á¸é, ¸ÅÅ©·Î·Î Çϼ¼¿ä -,.-
ÇÔ¼öÀÇ Àμö¸¦ Ãß°¡ÇÏ´ø°¡¿ä.

#113-2. ¾È¿µ±â 2005/04/13 (Wed)

typedef struct _test_struct {
    int aaa;
    void (*out)(void*, int,int);
} TEST_STRUCT;

TEST_STRUCT test_struct = {
    0xffff, test_out
};

void test_out(void* __this, int a,int b)
{
    TEST_STRUCT* _this = (TEST_STRUCT*)__this;
    printf("%d\r\n", _this->aaa);
}

ÀÌ·± ½ÄÀ¸·Î ÇÏ´Â ¹æ¹ý ¹Û¿¡´Â ¾ø½À´Ï´Ù.
this°¡ ÀÚµ¿À¸·Î µé¾î°¡°Ô ÇÏ·Á¸é ¸ÅÅ©·Î¸¦ ½á¾ß ÇÏ°í »ó¼ÓÀ» ¹Þ¾Æ¼­ È®ÀåÇÏ·Á¸é ¿ª½Ã ¸ÅÅ©·Î¸¦ ½á¾ß ÇÕ´Ï´Ù. (virtual tableÀÌ ºÙÀ¸¸é À§¿Í´Â ±¸ÇöÀÌ ´Þ¶óÁý´Ï´Ù) Ȥ½Ã ±¸ÇÒ ¼öÀÖÀ¸½Ã´Ù¸é microwinÀ̶õ °ÍÀÇ ¼Ò½º¸¦ ±¸Çغ¸¼¼¿ä. °Å±â¿¡ º¸¸é C·Î C++ÀÇ °ÅÀÇ ¸ðµç °ÍÀ» ±¸ÇöÇØ ³õ¾Ò½À´Ï´Ù.

#113-3. ¹Ù¶÷µ¹ÀÌ 2005/04/13 (Wed)
į¼ÝÇÕ´Ï´Ù
^0^


NAME / EMAIL
URL
SUBJECT
MESSAGE
ATTACH
ATTACH STYLE COOKIE  
[PREV] [NEXT] return


IRiS nX by NvyU =starry scape=