@ 2004-05-31 @
¼³Á¤ #
££. ¸ÅÅ©·Î¸¦ È°¿ëÇÑ (goto) Error; ó¸®
//Error handling macro for join failures #define JOIN_ERROR(x) {eLoginError = (x); goto Error;} //¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ¤Ñ static BOOL sPlayerJoinGame( GAME * game, APPCLIENTID idAppClient, MSG_CCMD_PLAYERNEW * msg) { ... LOGINERROR eLoginError = LOGINERROR_UNKNOWN; JOIN_ERROR(LOGINERROR_UNKNOWN); ... return TRUE; Error: SendError(idAppClient, eLoginError); return FALSE; }££. fatal error C1083: ¹Ì¸® ÄÄÆÄÀÏµÈ Çì´õ ÆÄÀÏÀ» ¿ ¼ö ¾ø½À´Ï´Ù. 1. ÇÁ·ÎÁ§Æ® ¼Ó¼º -> ¹Ì¸® ÄÄÆÄÀÏµÈ Çì´õ: »ç¿ë(/Yu) 2. ¹Ì¸® ÄÄÆÄÀÏµÈ Çì´õ·Î ÁöÁ¤µÈ ÆÄÀÏÀÌ StdAfx.h¶ó¸é * °æ·Î ¾Ë¾Æº¸±â //---------------------------------------------------------------------------- * ¸±¸®Áî ¸ðµå¿¡¼ Ãâ·Ââ¿¡ ¹®ÀÚ¿ Ç¥½Ã char str256; wsprintf(str,">> Language set to '%s'\n", LanguageGetCurrentName() ); OutputDebugString(str);
* º°°³ÀÇ window¿¡ printf()¸¦ »ç¿ëÇؼ Ãâ·ÂÇÏ´Â ¹æ¹ý
-.µî·Ï; #pragma comment(linker, "/entry:WinMainCRTStartup /subsystem:console" )
//-----------------------------------------------------------------------------.»ç¿ë; ÀϹÝÀûÀÎ printf()¸¦ »ç¿ë - printf("%f %f %f\n",vNodePos.x,vNodePos.y,vNodePos.z); * COM+/DCOM ½ÃÀÛÀ» À§ÇÑ ¼±ÇàÁ¶°Ç (ÀÎÅͳݿ¡¼ ÆÛ¿Â ±Û)
1.C++À» ÀÌ¿ëÇÑ °´Ã¼ÁöÇâ(Class°³³ä) °³³äÀÇ ÀÌÇØ.
//-----------------------------------------------------------------------------> ½ÃÁß¿¡ ³ª¿ÍÀÖ´Â c++¿¡ °ü·ÃµÈ ÀÔ¹®¼¸¦ Çѹø º¸½Ã±æ ¹Ù¶ø´Ï´Ù. ±×Áßoverriding/overloading ¿¡ ´ëÇÑ ÀÌÇرîÁö¸¸ ¸¶Ä¡¸é Áغñ ³¡(teach youself C++ Á¤º¸¹®È»ç ±ÇÀå) 2.Window ÇÁ·Î±×·¡¹Ö¿¡ ´ëÇÑ ÀÌÇØ. -> Visual C++À» »ç¿ëÇÑ ¾îÇø®ÄÉÀÌ¼Ç °³¹ß¹æ¹ý¿¡ ´ëÇÑ ±âº»ÀûÀÎ ÀÌÇØ. ¸¹Àº °É ÇÒ ÇÊ¿ä´Â ¾ø½À´Ï´Ù.
1) MFCÀÇ ±âº»ÀûÀÎ ¶óÀ̺귯¸® »ç¿ë¹ý
ÀÌ»ó µü ¼¼°¡Áö ÇÒ Á¤µµ¸¸ ÇÊ¿äÇÕ´Ï´Ù. 2) SDI ¹× ´ÙÀ̾ó·Î±× ÀÎÅÍÆäÀ̽º 3) Æ®¸®ÄÁÆ®·Ñ, ¸®½ºÆ® ÄÁÆ®·Ñ, ODBC TRANSECTION µÎ²¨¿î Bible óÀ½ºÎÅÍ ³¡±îÁö ÇÏÁö ¸¶½Ã°í ÇÊ¿äºÎºÐ¸¸ °ñ¶ó¼ ÇϽñæ... * Font ¼³Á¤
char str100;
SetTextColor(hdc,RGB(255,0,255)); // Font »ö»ó SetBkColor(hdc,RGB(0,0,255)); SetBkMode(hdc,TRANSPARENT); // ±ÛÀÚ µÞ¹è°æ ¹ÙÅÁ»ö°ú °°ÀÌ Ã³¸® wsprintf(str," Total_Point = %d ",TotalPoint); TextOut(hdc,10,10,str,22); SetTextAlign(hdc,TA_LEFT); Á¤·Ä¹æ½Ä SetTextColor(hdc,RGB(0,0,0)); ¹®ÀÚ¿ »ö»ó Á¶Á¤
( (CMainFrame *)(this->GetParentFrame())Mytab->m_Page3.CheckNormal(g->m_togDisplayNormal);
( (CDirect9MFCView *)(((CMainFrame *)m_pMainWnd)->GetActiveView()) )->OpenFileMD2Data();
• %l64d : signed 64-bit integer • %l64u : unsigned 64-bit integer
# Á¤¼öÇü µ¥ÀÌŸ ŸÀÔ(°ªÀÇ ¹üÀ§¿¡ µû¶ó short, int, longÀ¸·Î ºÐ·ù)
• short - char¸¦ Á¦¿ÜÇÑ ÃÖ¼ÒÀÇ Á¤¼öÇüÀ̸ç, 16ºñÆ® ÀÌ»óÀÇ È¯°æ¿¡¼ 2¹ÙÀÌÆ®(16ºñÆ®)·Î ó¸®
hortÇüÀÌ °¡Áú ¼ö ÀÖ´Â °ªÀÇ ¹üÀ§´Â -32,768 ~ 32,767À̸ç,
• int - ½Ã½ºÅÛÀÇ ±âº»ÀûÀÎ Á¤¼öÇü º¯¼öÀ̸ç, 16ºñÆ® ȯ°æ(DOS, win95ȯ°æ)À̳ª 32ºñÆ® ȯ°æ(win2000ȯ°æ)¿¡¼ °ªÀÇ ¹üÀ§´Â µ¿ÀÏ.
16ºñÆ® ȯ°æ¿¡¼´Â 2¹ÙÀÌÆ®, 32ºñÆ® ȯ°æ¿¡¼´Â 4¹ÙÀÌÆ®(32ºñÆ®)·Î ó¸®
• long - Á¤¼öÇü Áß °¡Àå Å« »çÀÌÁ Ç¥ÇöÇÒ ¼ö ÀÖÀ¸¸ç, intÇüÀÌ °¡Áú ¼ö ÀÖ´Â °ªÀÇ ¹üÀ§´Â 16ºñÆ®, 32ºñÆ®¿¡ µû¶ó °¢°¢ ´Ù¸¨´Ï´Ù.
16ºñÆ® ȯ°æ¿¡¼´Â shortÇü°ú °ªÀÇ ¹üÀ§(-32,768 ~ 32,767)°¡ µ¿ÀÏÇϸç
32ºñÆ® ȯ°æ¿¡¼´Â -2,147,483,648 ~ 2,147,438,647.
16ºñÆ® ȯ°æ°ú 32ºñÆ® ȯ°æ¿¡¼ Å©±â°¡ µ¿ÀÏÇÏ°Ô 4¹ÙÀÌÆ®(32ºñÆ®)·Î ó¸®
• unsigned short - unsigned Áï, 0°ú ¾ç¼ö¸¸À» °¡Áú ¼ö ÀÖ´Ù´Â °ÍÀ» Á¦¿ÜÇÏ°í´Â shortÇü°ú µ¿ÀÏ
longÇüÀÇ °ªÀÇ ¹üÀ§´Â -2,147,483,648 ~ 2,147,438,647.
´Ü, À½¼ö¸¦ °¡ÁöÁö ¾ÊÀ¸¹Ç·Î ºÎÈ£ºñÆ®°¡ ÇÊ¿ä¾ø±â ¶§¹®¿¡ Ç¥ÇöÇÒ ¼ö ÀÖ´Â °ªÀÇ ¹üÀ§°¡ ´õ ³Ð½À´Ï´Ù.
• unsigned int - unsigned Áï, 0°ú ¾ç¼ö¸¸À» °¡Áú ¼ö ÀÖ´Ù´Â °ÍÀ» Á¦¿ÜÇÏ°í´Â intÇü°ú µ¿ÀÏunsigned shortÇüÀÇ °ªÀÇ ¹üÀ§´Â 0 ~ 65,535.
ºÎÈ£ºñÆ®°¡ ÇÊ¿ä¾ø±â ¶§¹®¿¡, Ç¥ÇöÇÒ ¼ö ÀÖ´Â °ªÀÇ ¹üÀ§´Â 0 ~ 4,294,967,295.
• unsigned long - unsigned Áï, 0°ú ¾ç¼ö¸¸À» °¡Áú ¼ö ÀÖ´Ù´Â °ÍÀ» Á¦¿ÜÇÏ°í´Â longÇü°ú µ¿ÀÏ.
ºÎÈ£ºñÆ®°¡ ÇÊ¿ä¾ø±â ¶§¹®¿¡, Ç¥ÇöÇÒ ¼ö ÀÖ´Â °ªÀÇ ¹üÀ§´Â 0 ~ 4,294,967,295.
Áï ÁÖ¼Ò°ªÀÌ 0x00000000 ~ 0xFFFFFFFF ±îÁöÀÇ °ªÀ» °¡Áø´Ù.
ÁÖ¼Ò°ªÀÇ °¡Áö¼ö´Â 2 ÀÇ 32 ½Â ¹ÙÀÌÆ®, Áï RAM Àº ÃÖ´ë 4 GB ±îÁö ¹Û¿¡ »ç¿ëÇÒ ¼ö ¾ø´Ù. ÀÌ ¶§¹®¿¡ 32 ºñÆ® ¿î¿µÃ¼Á¦¿¡¼´Â RAMÀÇ ÃÖ´ë Å©±â°¡ 4 GB ·Î Á¦ÇѵȴÙ.
Bit¿¬»ê #
#. & (AND) ¿¬»êÀÚ ; ¿øÇÏ´Â ºñÆ®¸¸ º¯°æ
-. °øÅëºÎºÐ ±¸Çѱâ
¾à°£ Á¦ÇÑµÈ °æ¿ìÁö¸¸ ¿¡¶óÅ佺Å׳׽ºÀÇ Ã¼¸¦ ÀÌ¿ëÇÏ¿© ¼Ò¼ö¸¦ ±¸ÇÒ ¶§ ó·³ ¹è¿¿¡ 1°ú 0¸¸ ³Ö¾î, Âü, °ÅÁþÀ» ±¸º°ÇÒ ¶§ if¹®À» »ç¿ëÇÏ´Â °Í º¸´Ù ºü¸£°Ô ÀÛµ¿
void samesame(int *a, *b, int *c) // a, b, c Èĺ¸¼ýÀÚ ¹è¿ÀÇ ±³ÁýÇպκÐÀ» ±¸ÇÔ { // cf.ÀÌ ÇÔ¼ö´Â C¾ð¾î ½ºµµÄí ÀÚµ¿Ç®ÀÌ ÇÁ·Î±×·¥¿¡ »ç¿ë int i; for( i=1; i<=9; i++ ) a[i]=a[i]&b[i]&c[i]; // ¼Â ´Ù 1À̸é 1ÀúÀå, Çϳª¶óµµ 0À̸é 0ÀúÀå }
#. | (OR) ¿¬»êÀÚ ; ¿øÇÏ´Â ºñÆ®¸¦ 1·Î ¹Ù²Ù°í ½ÍÀ» ¶§, & ¿¬»êó·³ »ç¿ë
#. ^ (XOR) ¿¬»êÀÚ ; °ª ±³È¯ (µ¿ÀÛ ´À¸²)
void swap(int *a, *b) { *a^=*b; *b^=*a; *a^=*b; // ÀÌ ¼¼¹øÀÇ µ¿ÀÛÀ¸·Î a¿Í bÀÇ °ªÀ» ±³È¯ }cf.0À¸·Î ÃʱâÈ ÇÒ ¶§, a^=a¸¦ Çϸé a°¡ 0À¸·Î ÃʱâÈ
#. ~ (NOT) ¿¬»êÀÚ : Á¤¼öÇü º¯¼öÀÇ ÃÖ´ñ°ªÀ» ±¸ÇÒ ¶§
#include <stio.h> int main() { int a=1; char b=1; __int64 c=1; a<<=31; b<<=7; printf("%d %d, ~a, ~b); // °¡Àå ¿À¸¥ÂÊÀÇ ºñÆ®¸¦ °¡Àå ¿ÞÂÊÀ¸·Î À̵¿½ÃÅ°°í ~¿¬»êÀ¸·Î °¡Àå ¿ÞÂʺñÆ®¸¸ »©°í ÀüºÎ 1·Î ¸¸µé¾î ÃÖ´ë°ªÀ» Ãâ·Â // (ºÎÈ£ÀÖ´Â º¯¼ö´Â °¡Àå ¿ÞÂÊÀÇ ºñÆ®´Â À½¼ö¸¦ ³ªÅ¸³¾ ¶§ »ç¿ë) } ÇØ´ç ºñÆ®¸¸ Á¢±Ù/º¯°æ ÇÏ´Â ¹æ¹ý #µ¥ÀÌÅÍÀÇ ÇÑ ºñÆ®¸¸ Á¶ÀÛÇÏ´Â ¹æ¹ýÀ¸·Î AND(&) ¶Ç´Â OR(|) ¿¬»êÀÚ¸¦ ÀÌ¿ëÇÑ´Ù. ¿¹¸¦ µé¸é,
unsigned char a = 0; ·Î ¼±¾ð/Á¤ÀǵǾúÀ» ¶§
'1'·Î ¼¼Æ®ÇÏ´Â ¹æ¹ý : a |= 0x08; // ºñÆ® 3¹ø ¼¼Æ® '0'À¸·Î Ŭ¸®¾î ÇÏ´Â ¹æ¹ý : a &= ~0x08; // ºñÆ® 3¹ø Ŭ¸®¾î Shift ¿¬»êÀÚ (ºü¸§) #1. ¿ÞÂÊshift (<<)
¿ÞÂÊÀ¸·Î 1Ä À̵¿½Ã¸¶´Ù *2¾¿ Ä¿Áø´Ù(ºó°ø°£Àº 0À¸·Î ä¿ò)
2. ¿À¸¥ÂÊshift (>>)
¿À¸¥ÂÊÀ¸·Î 1Ä À̵¿½Ã¸¶´Ù /2¾¿ ÀÛ¾ÆÁø´Ù.
3. ¿À¸¥ÂÊshift (>>>)(¾ç¼öÈ ½ÃÅ´) ¦£ JAVA¿¡¼´Â signed right shift operator¶ó ÇÑ´Ù. ¦¦ ºó°ø°£Àº ºÎÈ£ºñÆ®À¸·Î ä¿î´Ù(¾ç¼ö¿Í À½¼öÀÇ Ã³¸®°¡ ´Ù¸§)
¦£ JAVA¿¡¼´Â unsigned right shift operator¶ó ÇÑ´Ù.
a << 1; 2 ¹è¦¦ ºó°ø°£Àº 0À¸·Î ä¿î´Ù.
a << 2; 4 ¹è
#.Shift ¿¬»êa << 3; 8 ¹è a << 4; 16 ¹è
a << 4 - a; 15 ¹è
a << 5; 32 ¹èa << 4 + a; 17 ¹è a << 6; 64 ¹è
a << 6 - a << 2; 60¹è
// cf. enum...
Inline DWORD SETBIT(DWORD & dwBitSet, int bit) {
Return dwBitSet |= (1<<bit);
}¿¬»êÀÚ ¿À¹ö·Îµù(operator overloading) È°¿ë¿¹ #class cGroup { public: // Group Types const static enum EGROUP_TYPES { KGROUP_TYPE_1, KGROUP_TYPE_2, KGROUP_TYPE_3, KGROUP_TYPE_4, KGROUP_TYPE_COUNT }; int m_GroupTypeValues[ KGROUP_TYPE_COUNT ]; public: cGroup( void ); ~cGroup(); void operator/= ( int nValue ); void operator*= ( int nValue ); void operator/= ( float fValue ); void operator*= ( float fValue ); void operator+= ( cGroup group ); void operator-= ( cGroup group ); BOOL operator== ( cGroup group ); BOOL operator!= ( cGroup group ); BOOL operator>= ( cGroup group ); BOOL operator<= ( cGroup group ); BOOL operator> ( cGroup group ); BOOL operator< ( cGroup group ); cGroup operator+ ( cGroup group ); cGroup operator- ( cGroup group ); }; void cGroup::operator/= (int nValue) { m_GroupTypeValues[ KGROUP_TYPE_1 ] /= nValue; m_GroupTypeValues[ KGROUP_TYPE_2 ] /= nValue; m_GroupTypeValues[ KGROUP_TYPE_3 ] /= nValue; m_GroupTypeValues[ KGROUP_TYPE_4 ] /= nValue; } HIWORD(I)ÀÇ ¸ÅÅ©·ÎÇÔ¼ö Á¤ÀÇ #((WORD)(((DWORD)(l) >> 16) & 0xFFFF))
HIWORD(I)ÀÇ ¸ÅÅ©·ÎÇÔ¼ö Á¤ÀÇÀ̱º¿ä.
32ºñÆ® Á¤¼öÀÇ »óÀ§ 16ºñÆ®¸¦ ±¸ÇÏ´Â µ¥ ¾µ ¼ö ÀÖ½À´Ï´Ù.
1. (I) : ¸ÅÅ©·Î Á¤ÀÇÀ̹ǷΠI¸¦ °ýÈ£·Î ½Î¼ ¸ÅÅ©·Î°¡ Àü°³µÉ ¶§ ¿À·ù°¡ µÇ´Â °ÍÀ» ¹æÁöÇÔ
2. (DWORD)(I) : I ÀÚ¸®¿¡ ġȯµÇ´Â ¼ö¸¦, ŸÀÔ¿¡ »ó°ü¾øÀÌ ¹«Á¶°Ç ºÎÈ£¾ø´Â 32ºñÆ® Á¤¼ö·Î º¯È¯ 3. (DWORD)(I) >> 16 : ¿À¸¥ÂÊÀ¸·Î 16ºñÆ® ½¬ÇÁÆ®. ÇÏÀ§ 16ºñÆ®¸¦ ¹ö¸®°í »óÀ§ 16ºñÆ®¸¦ ÇÏÀ§·Î ÀÚ¸® ¿Å±è 4. ((DWORD)(I) >> 16) & 0xFFFF : »ç½Ç ÇÊ¿ä¾ø´Â °ÍÀÌÁö¸¸ »óÀ§ 16ºñÆ® ºÎºÐÀ» ¸ðµÎ 0À¸·Î ä¿ò 5. (WORD)(((DWORD)(I) >> 16) & 0xFFFF) : ºÎÈ£¾ø´Â 16ºñÆ® Á¤¼öÇüÀ¸·Î º¯È¯ 6. ((WORD)(((DWORD)(I) >> 16) & 0xFFFF)) : ¸ÅÅ©·Î ÇÔ¼öÀ̹ǷΠÁ¿쿡 °ýÈ£¸¦ ½Ó
#include <iostream>
* ±âÁ¸ÀÇ C API¿¡ stringÀ» ³Ñ±â´Â ¹æ¹ý#include <string> using namespace std; void main(){
char *s = "123";
}string s1 = (string)s; string s2 = string(s); cout << s1 << endl; cout << s2 << endl;
void doSomething(const char * pString){...};
#.ANSI Äڵ忡¼ UTF-8·Î °¡±â À§Çؼ´Â ´ÙÀ½°ú °°Àº º¯È¯°úÁ¤À» °ÅÃÄ¾ß ÇÕ´Ï´Ù.string s; doSomething( s.c_str() ); ANSI( MutiByte ) -> UCS-2( WideByte ) -> UTF-8( MultiByte ) void foo( const char *in, char *out, int nOut ) { USES_CONVERSION; wchar_t *wc = A2W( in ); // ANSI to UCS-2 WideCharToMultiByte( CP_UTF8, 0, wc, -1, out, nOut, 0, 0 ); // UCS-2 to UTF-8 }À©µµ¿ì¿¡¼´Â MultiByteToWideChar()¸¦ Á¦°øÇÕ´Ï´Ù. À¯»ç Æ÷¸ËÀ¸·Î´Â mbstowcs()°¡ ÀÖÁö¸¸ ÀÌ ÇÔ¼ö´Â UTF-8Àº Á¦°øÇÏÁö ¾Ê½À´Ï´Ù.
Âü°í·Î A2W³ª USES_CONVERSIONÀº ATL °ü·Ã ÇÔ¼öÀÔ´Ï´Ù.
¹Ý´ë·Î º¯È¯ÇÒ 떄´Â MultiByteToWideChar()¿Í W2A()¸¦ ÀÌ¿ëÇÏ½Ã¸é µË´Ï´Ù. À§¿¡µµ Àû¾î³ùÁö¸¸ ANSI³ª UTF-8À̳ª ´Ù MultiByteÀÔ´Ï´Ù. A2W()´Â ³»ºÎÀûÀ¸·Î MultiByteToWideChar()¸¦, W2A()´Â ³»ºÎÀûÀ¸·Î WideCharToMultiByte()¸¦ È£ÃâÇÕ´Ï´Ù.
* char --> wchar·Î º¯È¯
char szSource[] = "Text to convert"; wchar szDest[100]; MultiByteToWideChar( GetACP(), 0, szSource, -1, szDest, sizeof(szDest)/sizeof(szDest[0]) );
* #include <atlbase.h>
T2A <-- tchar¸¦ ¸ÖƼ¹ÙÀÌÆ® ½ºÆ®¸µÀ¸·Î.. T2W <-- tchar¸¦ À¯´ÏÄÚµå ½ºÆ®¸µÀ¸·Î... W2A <-- À¯´ÏÄڵ带 ¸ÖƼ¹ÙÀÌÆ®·Î A2W <-- ¸ÖƼ¹ÙÀÌÆ®¸¦ À¯´ÏÄÚµå·Î W2T A2T
* ¹®ÀÚ¿ ºñ±³
if (strcmp(szJin,"jin")==0) {
// ÇÏ°í½ÍÀº ÀÏ
}´ë¼Ò¹®ÀÚ ±¸ºÐ¾øÀÌ ºñ±³ÇÏ·Á¸é stricmp ÇÔ¼ö¸¦, À¯´ÏÄڵ带 »ç¿ëÇϽ÷Á¸é lstrcmp ÇÔ¼ö¸¦ ¾´´Ù.
#include <imm.h>
// ÇÑ¿µ Àüȯ
void CChattingDlg::SetIMEMode( HWND hWnd, BOOL bHanMode ) {
ImmGetConversionStatus(hIMC,&dwConv,&dwSent);
dwTemp = dwConv & ~IME_CMODE_LANGUAGE; // »óŸ¦ ¹Ù²ß´Ï´Ù. if( bHanMode )
dwTemp |= IME_CMODE_NATIVE; // ÇѱÛ
else
dwTemp |= IME_CMODE_ALPHANUMERIC; // ¿µ¹®
dwConv = dwTemp; }
• Á¤¼öÈ ÇÔ¼ö´Â ½Ç¼öÇü µ¥ÀÌÅÍ¿¡¼ Á¤¼öºÎ¸¸À» ÃëÇÏ´Â, Áï ¼Ò¼öÁ¡ ÀÌÇÏÀÇ ¼Ò¼öºÎ¸¦ À߶ó ¹ö¸®´Â ÇÔ¼öÀÌ´Ù. ¼Ò¼öºÎ¸¦ À߶ó ¹ö¸°´Ù°í Çؼ °è»ê °á°ú°¡ Á¤¼ö°¡ µÇ´Â °ÍÀº ¾Æ´Ï¸ç ¸®ÅÏ°ªÀº ¿©ÀüÈ÷ ½Ç¼öÀÌ´Ù. ½Ç¼ö°ªÀÇ ¼Ò¼öºÎ¸¸À» 0À¸·Î ¸¸µç´Ù°í »ý°¢ÇÏ¸é µÈ´Ù. Á¤¼öÈ ÇÔ¼ö¿¡´Â ´ÙÀ½ µÎ °¡Áö°¡ ÀÖ´Ù
¢¹ double floor( double x ); // ÁÖ¾îÁø Àμöº¸´Ù Å©Áö ¾ÊÀº ÃÖ´ë Á¤¼ö
• C ¾ð¾î´Â ¹Ý¿Ã¸² ÇÔ¼ö¸¦ µû·Î Á¦°øÇÏÁö ¾Ê°í, ±âÁ¸ ÇÔ¼ö¸¦ ÀÀ¿ëÇÑ´Ù. ¼Ò¼öÁ¡ ÀÌÇϸ¦ ÀÚ¸£´Â ¹æ½ÄÀ¸·Î ¼Ò¼öÁ¡ ÀÌÇϸ¦ ¹ö¸®°í Á¤¼öºÎ¸¸À» ÃëÇÔ
floor(3.14); // °á°ú´Â 3.0
¢¹ double ceil( double x ); // ÁÖ¾îÁø Àμöº¸´Ù ÀÛÁö ¾ÊÀº ÃÖ¼Ò Á¤¼öfloor(-3.14); // °á°ú´Â -4.0 ¼Ò¼öÁ¡ ÀÌÇϸ¦ ¿Ã¸²Çؼ Á¤¼öºÎ¸¦ 1Áõ°¡
ceil(3.14); // °á°ú´Â 4.0
ceil(-3.14) // °á°ú´Â -3.0
1.½Ç¼ö x¸¦ ¹Ý¿Ã¸²ÇÑ °ª = floor(x+0.5); // 0.5 ÀÌ»óÀÇ °ªÀ» ¹Ý¿Ã¸²
¢Â È£Ãâ°üÇà
cf.ceil(x-0.5); // 0.5 ÃÊ°ú °ªÀ» ¹Ý¿Ã¸²
2.¼Ò¼öÁ¡ µÑ °ÀÚ¸®¿¡¼ ¹Ý¿Ã¸² = floor(x*10+0.5)/10;3.¼Ò¼öÁ¡ n¹ø° ÀÚ¸®¿¡¼ ¹Ý¿Ã¸²µÇ´Â ÇÔ¼ö¸¦ ¸¸µé ¼ö Àִµ¥ ¾ÆÁÖ °£´ÜÇϹǷΠ¸ÅÅ©·Î ÇÔ¼ö·Î Á¤ÀÇ
#define banollim(x,dig) (floor((x)*pow(10,dig)+0.5)/pow(10,dig))
4.double round(double x); // ¹Ý¿Ã¸² ÇÔ¼ö, À½¼öÀÏ °æ¿ì ¹Ý³»¸²À» ÇÑ´Ù.
#include <math.h>
double round( double x) {
return ( (x>0> ? floor(x+0.5) : ceil(x-0.5);
}
_cdecl - ¸¶Áö¸· ÀÎÀÚºÎÅÍ ½ºÅÿ¡ ÀúÀåÇϸç, ÇÔ¼ö¸¦ È£ÃâÇÑ ÂÊ¿¡¼ ½ºÅÃÀ» Á¤¸®ÇÑ´Ù.
¢Â void *realloc( void *memblock, size_t size );_stdcall - ¸¶Áö¸· ÀÎÀÚºÎÅÍ ½ºÅÿ¡ ÀúÀåÇϸç, È£ÃâµÈ ÇÔ¼ö°¡ ½ºÅÃÀ» Á¤¸®ÇÑ´Ù. _fastcall - ·¹Áö½ºÅÍ¿¡ ÀÎÀÚ µÎ °³¸¦ ³Ö°í, ¸¶Áö¸· ÀÎÀÚºÎÅÍ ½ºÅÿ¡ ÀúÀåÇϸç È£ÃâµÈ ÇÔ¼ö°¡ ½ºÅÃÀ» Á¤¸®ÇÑ´Ù. _stdcall Àº º¸Åë APIµéÀÌ »ç¿ëÇÏ°í ÀÖ´Ù. ±× ÀÌÀ¯´Â ½ºÅÃÀ» Á¤¸®ÇÏ´Â Äڵ尡 API ÂÊ¿¡ ÀÖ°Ô µÇ¸é ±× ¸¸Å ¸Þ¸ð¸®¸¦ Àý¾àÇÒ ¼ö Àֱ⠶§¹®ÀÌ´Ù. API´Â ¿©·¯ ´Ù¸¥ Ŭ¶óÀ̾ðÆ®¿¡ ÀÇÇؼ È£ÃâµÈ´Ù´Â °¡Á¤ ÇÏ¿¡ ±âµ¿ÇÑ´Ù.
Á¶Á¤ ´ë»óÀÌ µÇ´Â ¸Þ¸ð¸® ºí·°À» size¸¸Å ´Ù½Ã ÇÒ´çÇÑ´Ù.(À̶§, ¸Þ¸ð¸®·®À» ¹ÙÀÌÆ® ´ÜÀ§·Î Ç¥Çö)
¢Â ½Ã½ºÅÛ ÇØ»óµµ ±¸Çϱâ¸Þ¸ð¸®°¡ ºÎÁ·ÇÏ¿© ÇÒ´çÇÏÁö ¸øÇßÀ» °æ¿ì NULLÀ» ¸®ÅÏÇϸç, ¸Þ¸ð¸®´Â Á¦ÇÑÀûÀ̱⠶§¹®¿¡ µ¿Àû ÇÒ´ç½Ã Ç×»ó ¿¡·¯¸¦ °Ë»ç ÇؾßÇÑ´Ù.
HDC hDC = ::GetDC(NULL);
¢Â Àüó¸® ÀÀ¿ë// HDC hDC = CreateDC("DISPLAY", NULL, NULL, NULL); int width = GetDeviceCaps(hDC, HORZRES); int height = GetDeviceCaps(hDC, VERTRES); -.GetDeviceCaps()ÇÔ¼ö´Â Get device capabilities·Î½á DC¿Í ¿¬°üµÈ deviceÀÇ ¼º´ÉÀ» ±¸ÇÏ°íÀÚ ÇÒ ¶§ »ç¿ë
ÀÎÀÚ·Î ¿É¼ÇÀ» ÁÖ¸é ±× ¿É¼Ç¿¡ ÇØ´çÇÏ´Â °ªÀÌ ³ª¿À´Âµ¥, (ÀÎÀÚ Á¾·ù ¸¹À½ ^^)
HORZRES, VERTRES¸¦ ÀÎÀÚ·Î ³ÖÀ¸¸é µð½ºÇ÷¹ÀÌÀÇ Æø°ú ³ôÀÌ°¡ Çȼ¿ ´ÜÀ§·Î ³ª¿Â´Ù. void ConsoleCommandTableInit( void ) {
#define CONSOLE_DESC( desc ) sCommandTableAddCommandDescription(L##desc)
...#define CONSOLE_CMD( cmd, cheat, appType, gameType, func, valParam )\
STATIC_CHECK( (cheat) != NOT_CHEATS ||
(gameType) != COMMAND_SERVER, SERVER_SIDE_COMMANDS_NOT_ALLOWED_IN_RELEASE );\
sCommandTableRegisterCommand( NULL, L##cmd, cheat, appType, gameType, func, valParam)
ConsoleCommandTableFree();
...
ÄÜ¼Ö ¸í·É Á¤ÀÇ(ÇÔ¼ö È£Ãâ)
...#undef CONSOLE_CMD #undef CONSOLE_DESC
ConsoleAddEmotes(); // À̸ð¼Ç °ü·Ã Äָܼí·É Ãß°¡
}
timeGetTime()
¡á Win32API/ GetLocalTime(...); ¸Þ¸ðÀå_C_Time @ 1202_06_16 @
#pragma comment(lib, "winmm.lib")
GetTickCount()#include <mmsystem.h>
#include <Windows.h>
QueryPerformanceFrequency()QueryPerformanceCounter()- ¸î¸î CPU¿¡¼± Ŭ·°ÀÌ °Ç³Ê¶Ú´Ù´Â º¸°í°¡ ÀÖÀ½...
CPU Ŭ·°¿¡ »ó°üÀÌ ¾ø´Â timeGetTime()ÇÔ¼ö¸¦ »ç¿ë
1.VC6ÀÇ include Æú´õ¿¡ ÀÖ´Â WINUSER.H ¶Ç´Â zmouse.h »ç¿ë
* error LNK2001: unresolved external symbol _main ÀÌ ¿¡·¯°¡ ¹ß»ýÇÏ´Â µÎ°¡Áö ¿øÀÎ
#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
2.#define WM_MOUSEWHEEL 0x020A Ãß°¡#define WM_MOUSEWHEEL 0x020A #define WM_MOUSELAST 0x020A #else #define WM_MOUSELAST 0x0209 #endif /* if (_WIN32_WINNT < 0x0400) */ 1.Visual C++¿¡¼ ÇÁ·ÎÁ§Æ® ¼ÂÆÃÀÇ ¹®Á¦
ÇÁ·ÎÁ§Æ®¸¦ ¸¸µé ¶§ Win32 Application : WinMain ÇÔ¼ö¿¡¼ ½ÃÀÛÇÏ°Ô µÇ´Â GUI ÇÁ·Î±×·¥
À§ÀÇ ¿¡·¯´Â ´ëºÎºÐ GUI ÇÁ·Î±×·¥À» ¸¸µå·Á°í WinMain·Î ½ÃÀÛÇߴµ¥Win32 Console Application : main ÇÔ¼ö¿¡¼ ½ÃÀÛÇÏ´Â console ÇÁ·Î±×·¥À¸·Î Å©°Ô ±¸ºÐÀÌ µÈ´Ù.
ÇÁ·ÎÁ§Æ®¸¦ ¸¸µé ¶§ console applicationÀ» ¼±ÅÃÇÑ °æ¿ì·Î, ¹Ý´ë·Î WinMainÀÌ ¾ø´Ù°í ¿¡·¯°¡ ³ª¿À¸é GUI ÇÁ·ÎÁ§Æ®¸¦ ¼±ÅÃÇÏ°í¼ main ÇÔ¼ö¸¦ ÀÛ¼ºÇÑ °æ¿ìÀÌ´Ù.
ÇØ°áÀº ¼³Á¤À» ¹Ù²ãÁÖ¸é µÇ´Âµ¥, LinkÅÇ¿¡¼ /subsystem:consoleÀ» /subsystem:windows·Î ¹Ù²ãÁØ´Ù(¶Ç´Â »óȲ¿¡ µû¶ó¼ ±× ¹Ý´ë·Î ¼³Á¤)
ÀÌ ¿É¼ÇÀÇ ¿ªÇÒÀº ¸µÄ¿¿¡°Ô ÀÖ¾î¼ ÀÌ ÇÁ·Î±×·¥ÀÌ ¾î¶² ÇÔ¼ö·ÎºÎÅÍ ½ÃÀÛÇØ¾ß ÇÏ´ÂÁö¸¦ ¾Ë·ÁÁÖ´Â ¿ªÇÒÀ» ÇÑ´Ù. consoleÀ̶ó¸é mainÀ», windows¶ó¸é WinMainÀ» ã¾Æ¼ ±× ÇÔ¼ö¿¡¼ºÎÅÍ ÇÁ·Î±×·¥ÀÌ ½ÃÀÛÇÑ´Ù.
(cf. Jeffrey RitcherÀú Programming Applications for Windows 4th.) 2. ATL¿¡¼ ÄÁÆ®·ÑÀ» ¸¸µé ¶§ ¹ß»ý
µð¹ö±×¿¡¼´Â Àß ÄÄÆÄÀÏÀÌ µÇ´ø°Ô ¸±¸®Áî·Î ºôµåÇϸé Àú ¿¡·¯°¡ ³¯ ¼ö ÀÖ´Ù. ATL¿¡¼´Â »ý¼ºµÇ´Â ÄÚµåÀÇ Å©±â¸¦ ÃÖ¼ÒÈ Çϱâ À§Çؼ CRT (C RunTime) ÇÔ¼öÀÇ ÀϺθ¦ Á¦ÇÑÇÏ°í Àֱ⠶§¹®ÀÌ´Ù(Á¤È®È÷ ¸»ÇÏÀÚ¸é start up Äڵ带 ³ÖÁö ¾Ê´Â´Ù). ±×·±µ¥ ÇÁ·ÎÁ§Æ®¿¡¼ ƯÁ¤ C ÇÔ¼ö¸¦ »ç¿ëÇϸé ATL¿¡¼ Á¦ÇÑÇÑ CRTÀÇ ±â´ÉÀÌ ÇÊ¿äÇØÁö°í µû¶ó¼ ¿¡·¯°¡ ¹ß»ýÇÑ´Ù.
ÇØ°áÀº a. ÇÁ·ÎÁ§Æ® ¼¼Æÿ¡¼ predefined keyword¸¦ ã¾Æ¼ _ATL_MIN_CRT¸¦ Áö¿ì°í,
b. ÃʱâÈ°¡ ÇÊ¿äÇÑ CRT ÇÔ¼ö¸¦ »ç¿ëÇÏÁö ¾Ê´Â´Ù(MSDN¿¡ µû¸£¸é strcmp´ë½Å lstrcmp¸¦ »ç¿ëÇÏ´Â ½ÄÀ¸·Î ÇÇÇØ°¥ ¼ö ÀÖ´Ù°í ÇÔ)
(cf.MSDN¿¡¼ _ATL_MIN_CRT·Î »öÀο¡¼ °Ë»ö)
1.GetAsyncKeyState() ; ÇÔ¼ö°¡ È£ÃâµÈ ½ÃÁ¡ÀÇ Å° »óŸ¦ Á¶»çÇؼ ¸®ÅÏ
(GetAsyncKeyState( VK_LEFT )) ? (St_run=TRUE, St_rundir=2, Move_x -= 4 ) : NULL;
cf.GetKeyState() ; ¸¶Áö¸·À¸·Î Å°¸Þ½ÃÁö ¹ß»ý ÈÄÀÇ »óÅ º¯È¸¦ ¸®ÅÏÇÕ´Ï´Ù.(GetAsyncKeyState( VK_RIGHT ))? (St_run=TRUE, St_rundir=3, Move_x += 4 ) : NULL;
µû¶ó¼ GetKeyStateÇÔ¼ö´Â Å°º¸µå ¸Þ½ÃÁö ó¸® ·çƾ ³»¿¡¼¸¸ À¯È¿ÇÑ °ªÀ» ¸®ÅÏÇÑ´Ù°í »ý°¢ÇÏ¸é µË´Ï´Ù.
2.GetKeyboardState() - Çѹø¿¡ 256°³ÀÇ Å°»óŸ¦ ´Ù ¹Þ¾Æ¿À´Â ÇÔ¼ö±¸¿ä3.WndProc()¿¡¼ ó¸®
BYTE m_bKey£Û256£Ý; // Àü¿ªÀ¸·Î ¼³Á¤ ÇÑ´Ù¸é
4.ShiftÅ°¿Í Á¶ÇÕ ¿©ºÎ È®ÀÎmemset (m_bKey, 0, sizeof (m_bKey)); // Å°º¸µå Á¦¾î¸¦ À§ÇÑ ÃʱâÄ¡ ... LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) {
switch( message )
}{
case WM_KEYUP: //mark a key up
}
m_bKey /wParam/ = FALSE;
case WM_KEYDOWN: //mark a key downbreak;
m_bKey /wParam/ = TRUE;
break; return DefWindowProc( hWnd, message, wParam, lParam ); ... if(m_bKey 'R' ) ResetPhysics(); // ó¸®ÇÏ°í ½ÍÀº °÷¿¡¼ ó¸® if(GetKeyState(VK_SHIFT) & 0x8000) // Shift + if(GetKeyState(VK_SHIFT) < 0) // ShiftÅ°°¡ ´·ÁÁö¸é À½¼ö°ªÀ» ¸®ÅÏ BOOL bControlKeyDown1 = GetAsyncKeyState (VK_SHIFT) >> ((sizeof(SHORT) * 8) - 1); if( bControlKeyDown1 ) return TRUE; case WM_SYSKEYDOWN: Àº Alt Å°°¡ ´·ÁÁ³À» ¶§ À̺¥Æ® ¹ß»ý
RegisterRawInputDevicesÇÔ¼ö·Î ½Ã½ºÅÛ¿¡ Å°º¸µå, ¸¶¿ì½º À̺¥Æ®¸¦ µî·Ï,
½Ã½ºÅÛÀº ÇØ´ç À©µµ¿ì¿¡ WM_INPUT¸Þ¼¼Áö¸¦ ´øÁ® »ç¿ëÀÚ·Î ºÎÅÍ Input À̺¥Æ®°¡ µé¾î¿Ô´ÂÁö¸¦ ¾Ë ¼ö ÀÖ´Ù. RAWINPUTDEVICE rawInputDev[2]; ZeroMemory(rawInputDev, sizeof(RAWINPUTDEVICE)*2); // Å°º¸µå RAWINPUTDEVICE ±¸Á¶Ã¼ ¼³Á¤ rawInputDev[0].usUsagePage = 0x01; rawInputDev[0].usUsage = 0x06; rawInputDev[0].dwFlags = RIDEV_INPUTSINK; rawInputDev[0].hwndTarget = GetSafeHwnd(); //¸¶¿ì½º RAWINPUTDEVICE ±¸Á¶Ã¼ ¼³Á¤ rawInputDev[1].usUsagePage = 0x01; rawInputDev[1].usUsage = 0x02; rawInputDev[1].dwFlags = RIDEV_INPUTSINK; rawInputDev[1].hwndTarget = GetSafeHwnd(); if(FALSE == RegisterRawInputDevices(rawInputDev, 2, sizeof(RAWINPUTDEVICE))) { CString str; str.Format(_T("RegisterRawInputDevices Error %d"), GetLastError()); MessageBox(str); } LRESULT CRegisterRawInputDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { // TODO: Add your specialized code here and/or call the base class if(message == WM_INPUT) { //¿©±â¼ ¸¶¿ì½º/Å°º¸µå ÀÔ·Â ¸Þ½ÃÁö¸¦ È®ÀÎÇÒ ¼ö ÀÖ½À´Ï´Ù. // GetRawInputDevices ÇÔ¼ö¸¦ ÀÌ¿ëÇÏ¿© ÀÔ·ÂµÈ Á¤º¸¸¦ ¾Ë ¼ö ÀÖ½À´Ï´Ù. } return CDialog::WindowProc(message, wParam, lParam); }
#if defined( _DEBUG ) || defined( DEBUG )
¢¹ VOID OutputDebugString( LPCTSTR lpOutputString ); // string to be displayed#endif
WIn32 API Áß¿¡ MFCÀÇ TRACE¿Í °°Àº ±â´ÉÀ» ÇÏ´Â Debug ÇÔ¼ö·Î½á,
if (InitScene())ÀÌÇÔ¼ö¸¦ »ç¿ëÇϽøé Debugâ¿¡ ¸ÞÁö½Ã¸¦ º¸³¾ ¼ö ÀÖ°í ±×¸®°í DebugView¶ó´Â À¯Æ¿¸®Æ¼¿¡¼µµ È®ÀÎÇÒ ¼ö ÀÖ´Ù.(SysinternalÁ¦Ç°) ¢¹ cf.DXUTmisc.h //-------------------------------------------------------------------------------------- // Debug printing support // See dxerr.h for more debug printing support //-------------------------------------------------------------------------------------- void DXUTOutputDebugStringW( LPCWSTR strMsg, ... ); void DXUTOutputDebugStringA( LPCSTR strMsg, ... );
¢¹ trace ¹üÀ§ ¼³Á¤
//-------------------------------------------------------------------------------------- // debug constants & macros //-------------------------------------------------------------------------------------- #define TRACE_LEVEL 2 // 0 = no tracing, 1 = errors, 2 = major ops, 3 = minor operations
#if DEBUG && ISVERSION(DEVELOPMENT) && !ISVERSION(SERVER_VERSION)
# if( TRACE_LEVEL >= 1 ) # define TRACE1(fmt, ...) Trace(fmt, __VA_ARGS__) # endif # if( TRACE_LEVEL >= 2 ) # define TRACE2(fmt, ...) Trace(fmt, __VA_ARGS__) # endif # if( TRACE_LEVEL >= 3 ) # define TRACE3(fmt, ...) Trace(fmt, __VA_ARGS__) # endif #endif
Ŭ·¡½º »ó¼Ó½Ã ºÎ¸ð Ŭ·¡½º ÇÔ¼ö¿Í ÀÚ½Ä Å¬·¡½º ÇÔ¼öÀÇ »çÀÌÀÇ °ü°è¿¡¼ ºÎ¸ð Ŭ·¡½º ÇÔ¼ö°¡ °¡»óÇÔ¼öÀÎÁö, ÀÏ¹Ý ÇÔ¼ö ÀÎÁö¿¡ µû¶ó
ÀÚ½Ä Å¬·¡½º¿¡¼ ÇÔ¼ö¸¦ È£Ãâ ÇßÀ» ¶§ µ¿ÀÛ ¹æ½ÄÀÌ ´Þ¶óÁø´Ù.
1.Á¤Àû¿¬°á;
Ç×»ó ºÎ¸ðÀÇ Æ÷ÀÎÅÍ·Î ÇÔ¼ö¸¦ È£ÃâÇϸç,
2.µ¿Àû¿¬°á; virtual »ç¿ë¸¸ÀÏ ÀÚ½Ä Å¬·¡½º¿¡ Á¸ÀçÇÏ´Â ÇÔ¼ö¸¦ È£ÃâÇϱâ À§Çؼ´Â (ÀÚ½ÄŬ·¡¼*) ij½ºÆà ÇÑ´Ù.
°¡»óÅ×À̺íÀÌ »ý¼ºµÇ¾î ºÎ¸ð°¡ ¾Æ´Ñ ÀÚ½ÄÀÇ Æ÷ÀÎÅÍ°¡ ¾ò¾îÁø´Ù.
¸¸ÀÏ ÀÚ½ÄÀÌ ¾Æ´Ñ ºÎ¸ð ÇÔ¼ö¸¦ È£ÃâÇϱâ À§Çؼ´Â p2->ºÎ¸ðŬ·¡½º::ÇÔ¼ö(); ½ÄÀ¸·Î »ç¿ëÇÑ´Ù.
class person {
(virtual) void print(); // ---> ÇÔ¼öÀÇ ¿¬°á ¹æ½Ä °áÁ¤
};class student : public person {
void print();
};int main( ) {
person* p1 = new person();
}p1->print(); person* p2 = new student(); ((student*)p2)->print(); // ---> Á¤Àû¿¬°á¿¡¼ ÀÚ½Ä Å¬·¡½ºÀÇ ÇÔ¼ö È£Ãâ p2->person::print(); // ---> µ¿Àû¿¬°á¿¡¼ ºÎ¸ð Ŭ·¡½ºÀÇ ÇÔ¼ö È£Ãâ return 0;
// ¹æ½Ä 1 ---------------------------------------------
class TestClass { public:
void TestFunc(int n)
};{
printf("%d\n", n);
}void RunFunction( void (TestClass::*Func)(int) ) {
(this->*Func)(6); //Ŭ·¡½º ¸â¹ö ÇÔ¼öÀÇ Æ÷ÀÎÅÍ´Â Ç×»ó ±× Ŭ·¡½ºÀÇ ÇÔ¼ö ¶ó´Â°ÍÀ» ÁöÁ¤ ÇØ¾ß ÇÑ´Ù.
}// ¹æ½Ä 2 --------------------------------------------- class Test { public:
static void (*p)(int);
public:}; // void (Test::*p)(int) = &(Test::Print); // ¿¡·¯ void (*Test::p)(int) = Test::Print; // ½ÇÇà int main(int argc, char* argv[]) {
printf("Hello World!\n");
}TestClass ccc; ccc.RunFunction(&TestClass::TestFunc); Test a; a.p(3); Test::p(4); return 0; -1.Á¤È®È÷ (Test::*p)¿Í (*Test::p)´Â Â÷ÀÌ°¡ ÀÖ´Ù.
VC++¿¡¼
-2.¸â¹ö ÇÔ¼öÀÇ Æ÷ÀÎÅ͸¦ ÃëÇϱâ À§Çؼ± ÇØ´ç ¸â¹ö ÇÔ¼ö¸¦ static Å°¿öµå¸¦ »ç¿ëÇؼ ¼±¾ðÇÑ´Ù.(Test::*p)Çϸé ÄÄÆÄÀÏ·¯´Â ÀÌ°ÍÀ» __thiscall·Î ÀνÄÇÏÁö¸¸ (*Test::p)Çϸé __cdecl·Î ÀνÄÇؼ ¿À·ù°¡ ³ªÁö ¾Ê½À´Ï´Ù. Á¤Àû ¸â¹öÇÔ¼ö´Â ±âº»ÀûÀ¸·Î __cdeclÀ̱⠶§¹®¿¡ ¹ß»ýÇÑ ¿À·ù´Â conversion context°¡ ¾ø´Ù´Â °É·Î ³ª¿Â´Ù. ±×¸®°í ¾îÂ÷ÇÇ Á¤Àû ¸â¹ö ÇÔ¼ö Æ÷ÀÎÅÍÀ̹ǷΠa.p(3)¸¦ Çϳª Test::p(3)¸¦ Çϳª ¾îÂ÷ÇÇ class-scopeÀ̱⠶§¹®¿¡ ³»ºÎ µ¿ÀÛÀº ¶È °°´Ù.
Ŭ·¡½º´Â ·±Å¸ÀÓÀ¸·Î »ý¼ºµÇ±â ¶§¹®¿¡, ÀÏ¹Ý ¸â¹ö ÇÔ¼öÀÇ Æ÷ÀÎÅÍ´Â Äڵ尡 ½ÇÇàµÇ±â À§ÇØ ½ºÅÿ¡ º¹»çµÈ ¼ø°£ À¯È¿ÇÑ Æ÷ÀÎÅÍ°¡ ¾Æ´Ï´Ù.
Ŭ·¡½º¸¦ Åë°·Î ÇÁ·»µå·Î ÁöÁ¤ÇÒ ¼ö ÀÖ´Ù. Ŭ·¡½º ¼±¾ð¹®³»¿¡ ÇÁ·»µå·Î ÁöÁ¤ÇÏ°í ½ÍÀº Ŭ·¡½ºÀÇ À̸§À» ¹àÈ÷¸é µÈ´Ù. ´ÙÀ½ ¿¹´Â Any Ŭ·¡½º¸¦ Some Ŭ·¡½ºÀÇ ÇÁ·»µå·Î ÁöÁ¤ÇÏ´Â °ÍÀÌ´Ù.
class Some {
Any°¡ SomeÀÇ ÇÁ·»µå·Î ÁöÁ¤µÇ¾úÀ¸¹Ç·Î
friend class Any;
};....
AnyÀÇ ¸ðµç ¸â¹ö ÇÔ¼öµéÀº SomeÀÇ ¸ðµç ¸â¹ö¸¦ ¸¶À½´ë·Î ¾×¼¼½ºÇÒ ¼ö ÀÖ´Ù. µÎ Ŭ·¡½º°¡ ÇùÁ¶ÀûÀ¸·Î µ¿ÀÛÇØ¾ß ÇѴٰųª »óÈ£ Á¾¼ÓÀûÀÎ °ü°è¿¡ ÀÖÀ» ¶§ ÇÁ·»µå·Î ÁöÁ¤Çϸé Æí¸®ÇÏ´Ù.
¿¹)
#include <Turboc.h>
class Time {
friend class Date;
private:
int hour,min,sec;
public:
Time(int h,int m,int s) { hour=h;min=m;sec=s; }
};class Date { private:
int year,month,day;
public:
Date(int y,int m,int d) { year=y;month=m;day=d; }
};void OutToday(Time &t) {
printf("¿À´ÃÀº %d³â %d¿ù %dÀÏÀ̸ç Áö±Ý ½Ã°£Àº %d:%d:%dÀÔ´Ï´Ù.\n",
}
year,month,day,t.hour,t.min,t.sec);
void main() { } OutToday ÇÔ¼ö´Â Date Ŭ·¡½ºÀÇ ¸â¹ö ÇÔ¼ö·Î ¼±¾ðµÇ¾úÁö¸¸ Date°¡ TimeÀÇ ÇÁ·»µå Ŭ·¡½º·Î ÁöÁ¤µÇ¾î ÀÖÀ¸¹Ç·Î
OutToday´Â Time °´Ã¼ÀÇ ¸ðµç ¸â¹ö¸¦ ÀÐÀ» ¼ö ÀÖ´Ù. ½ÇÇà °á°ú´Â ¾ÕÀÇ ¿¹Á¦¿Í µ¿ÀÏÇÏ´Ù. °³³äÀûÀ¸·Î ÀÌÇØÇϱ⠽¬¿î °£´ÜÇÑ ¿¹Á¦¸¦ º¸¿´´Âµ¥ ½ÇÁ¦·Î ÇÁ·»µå Ŭ·¡½º ÁöÁ¤ÀÌ ²À ÇÊ¿äÇÑ ¿¹´Â ´Ù¼Ò Å©°í º¹ÀâÇÏ´Ù. MFC ¶óÀ̺귯¸®ÀÇ °æ¿ì ´ÙÀ½°ú °°Àº ÇÁ·»µå Ŭ·¡½ºÀÇ ¿¹°¡ ¸¹ÀÌ Á¸ÀçÇÑ´Ù.
¸ðµÎ ¾ÆÁÖ ¹ÐÁ¢ÇÑ °ü°è¿¡ Àִ Ŭ·¡½ºµéÀε¥ MFCÀÇ ±¸Á¶¸¦ °øºÎÇØ º¸¸é
ÀÌ Å¬·¡½ºµéÀÌ ¿Ö ÇÁ·»µå¿©¾ß ÇÏ´ÂÁö ¾Ë°Ô µÉ °ÍÀÌ´Ù. CView¿Í CDocument´Â ÇϳªÀÇ ½Çü¿¡ ´ëÇØ °¢°¢ ¿ÜºÎ¿Í ³»ºÎ¸¦ ´Ù·ç´Â °ü·ÃÀִ Ŭ·¡½ºÀÌ´Ù. CView´Â ÀÚ½ÅÀÌ È¸é¿¡ Ãâ·ÂÇÒ µ¥ÀÌÅ͸¦ Àбâ À§ÇØ CDocumentÀÇ ¸â¹ö¸¦ ¸¶À½´ë·Î ÀÐÀ» ¼ö ÀÖ¾î¾ß Çϸç CToolTipCtrl Ŭ·¡½º´Â ÅøÆÁÀ» º¸¿©ÁÙ ¹öÆ°À̳ª ¿µ¿ªÀ» ±¸Çϱâ À§ÇØ CToolBarÀÇ ¸â¹ö¸¦ ¾×¼¼½ºÇØ¾ß ÇÑ´Ù.
¼ö¾÷ ³»¿ë #20030422
-.·ÎÁ÷»ó¿¡ Á÷Á¢ÀûÀÎ »ó¼öÀÇ ´ëÀÔÀº ÁöÇâ
20030423 - ¹è¿-.break, continue ÀÇ »ç¿ë»ó Â÷ÀÌÁ¡
-.char a = getch();
20030424 - Æ÷ÀÎÅÍ-.Type(Çü)¿¡ ´ëÇÑ Á¤ÀÇ -.¹è¿Àº 0ºÎÅÍ ½ÃÀÛ
char a10; ¹®ÀÚ ¹è¿Àº »ó¼ö·Î Ãë±ÞµÇ±â ¶§¹®¿¡ 1:1·Î ´ëÀÀÇÔ
-.Æ÷ÀÎÅÍ; ¸Þ¸ð¸®¿¡ ´ëÇÑ ±âº»ÀûÀÎ ÀÌÇØ ÇÊ¿ä(4¹ÙÀÌÆ®)
--> ¹®ÀÚ¿À» ºñ±³ÇÒ ¶§´Â °¢°¢ÀÇ ¿ä¼Ò¸¦ ÀüºÎ È®ÀÎ
printf("%s", a); ¹®ÀÚ¿ Ãâ·Â
p=malloc(sizeof(char)*10); /* µ¿ÀûÀ¸·Î ¸Þ¸ð¸®¸¦ ÇÒ´ç */
memset(p,'&',sizeof(char)*10);
p[0]='a';
p[1]='b'; p[8]='q'; p[9]='\0'; printf("%s = %d \n",p,sizeof(p)); free(p);
-.Æ÷ÀÎÅÍ´Â ¹øÁö¸¦ °¡¸£Ä¡´Â ¼ýÀÚ°³³äÀ̱⠶§¹®¿¡ ¿¬»êÀÌ °¡´É
20030425 - ÇÔ¼ö
cf. Àμö¸¦ °¡¸£Ä¥ ¶§´Â ¹Ýº¹ÀÚ °³³äÀÌ ÀÖ´Ù.
int *a;
int b=10; a= &b; &Àº ÁÖ¼Ò ¿¬»êÀÚ int *a;
-.°¢ ±â´ÉÀ» ÇÔ¼öȽÃÄѼ ºÐ»ê±¸Á¶·Î Á¤ÀÇ --> ÇÊ¿äÇÒ ¶§ ±â´Éº°·Î È£Ãâ
20030428 - ±¸Á¶Ã¼; ±¸Á¶Ã¼ ³»¿¡ ´Ù¸¥ ±¸Á¶Ã¼ ¼±¾ðµµ °¡´É-.ÇÔ¼ö°¡ ³¡³ª¸é ÇÔ¼öÀÇ °¡Àμö(Áö¿ªº¯¼ö)´Â »ç¶óÁö°í,
Àü¿ªº¯¼ö´Â ÇÁ·Î±×·¥ Àüü¿¡ ¿µÇâÀ» ¹ÌÄ¡±â ¶§¹®¿¡ °¡´ÉÇÑ ÃÖ¼ÒÇѸ¸ »ç¿ë
-.scanf()·Î ¹®ÀÚ¸¦ ÀÔ·Â ¹ÞÀ» ¶§´Â ¹®ÀÚ°¡ Â÷ÁöÇÒ ¿µ¿ªÀÇ ¸Þ¸ð¸®¸¦ ¹Ì¸® Àâ´Â´Ù.
(¹è¿À̳ª malloc µî)
-.µ¥ÀÌŸ 󸮸¦ À§ÇØ DBÀÇ Çʵå¿Í ·¹ÄÚµå °³³äÀ» »ç¿ë
20030429-.±¸Á¶Ã¼ ¼±¾ð ºÎºÐ ³»¿¡¼ ¹Ù·Î ÃʱâÈÇÒ ¼ö ¾ø´Ù -.structÀÇ pointer³»ÀÇ ±¸¼ºÀÎÀÚ(Çʵå)¸¦ ÁöÁ¤Çϱâ À§Çؼ± (->)Çʵå¸í Çü½Ä -.ÇÑ °³ÀÇ ÆÄÀÏÀ» »ç¿ëÇÒ °æ¿ì,
¿°í (ÆÄÀÏ ÀÔ·Â ¶Ç´Â ÀúÀå) ´Ý°í > ¿°í (ÆÄÀÏ ÀÔ·Â ¶Ç´Â ÀúÀå) ´Ý°í ...
-.head ÆÄÀÏ·Î »ç¿ëÀÚ Á¤ÀÇ ºÎºÐ µû·Î ÀúÀå
-.#defineÀ¸·Î Á¤ÀÇµÈ »ó¼öÀ̸§Àº ÀϹÝÀûÀ¸·Î ¸ðµÎ ´ë¹®ÀÚ·Î »ç¿ë
¸Þ¸ðÀåÀ¸·Î °¡±â
|
Â÷°¡¿î Â÷¿Í Â÷°¡¿î ¹äÀº ÂüÀ» ¼ö ÀÖÁö¸¸ Â÷°¡¿î À̾߱â´Â °ßµðÁö ¸øÇÑ´Ù(Áß±¹¼Ó´ã) ¸Þ¸ðÀå_MFC edu2014 WikiSeed ½Å¿ë_200910_À§±â¿¡_ºû³_±â¾÷ÀÇ_±³ÈÆ |