From: karunakar A.K. <k_k...@ya...> - 2006-08-21 14:51:25
|
Dear All Output of the following program is 1. Please explain me the reason. with regards karunakar #include <iostream.h> #include <conio.h> class Object { public: Object() { } }; void main() { cout << "\nSize = " << sizeof(Object); } --------------------------------- Here's a new way to find what you're looking for - Yahoo! Answers Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it NOW |
From: sudipta b. <tup...@ya...> - 2008-06-27 18:20:29
|
Hi all, I am learning C programing under windows.I was trying to compile the following code. #include <windows.h> int _stdcall WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdline,int nCmdShow) { HWND h; h=CreateWindow("BUTTON","Press Me",WS_OVERLAPPEDWINDOW,10,10,150,100,0,0,h,0); ShowWindow(h,nCmdShow); MessageBox(0,"Hi!","Waiting",MB_OK); return 0; } But I am getting an error as follows:- 5 C:\Dev-Cpp\tupai\Winapp3.cpp cannot convert `HWND__*' to `HINSTANCE__*' for argument `11' to `HWND__* CreateWindowExA(DWORD, const CHAR*, const CHAR*, DWORD, int, int, int, int, HWND__*, HMENU__*, HINSTANCE__*, void*)' . I have worked with C programs under DOS but not under windows, so I am unable to understand what it means and what rectification is needed in the program. And also can someone suggest me some books/websites from where I can learn C under windows efficiently. Regards Sudipta Lal Basu Student, M.Tech (Structural Engineering) G-51, Jawahar Bhawan IIT Roorkee Ph-9897509977 Send instant messages to your online friends http://uk.messenger.yahoo.com |
From: Fernando L. <fer...@gm...> - 2008-06-28 17:39:10
|
Argument 11 (h) should be of type HINSTANCE and it is declared as HWND, see http://msdn.microsoft.com/en-us/library/ms632679(VS.85).aspx. There is a good tutorial at http://winprog.org/tutorial/, or get Programming Windows by Charles Petzold. Best regards, Fernando On Fri, Jun 27, 2008 at 3:20 PM, sudipta basu <tup...@ya...> wrote: > > Hi all, > I am learning C programing under windows.I was trying to compile the following code. > > #include <windows.h> > int _stdcall WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdline,int nCmdShow) > { > HWND h; > h=CreateWindow("BUTTON","Press Me",WS_OVERLAPPEDWINDOW,10,10,150,100,0,0,h,0); > ShowWindow(h,nCmdShow); > MessageBox(0,"Hi!","Waiting",MB_OK); > return 0; > } > > But I am getting an error as follows:- > 5 C:\Dev-Cpp\tupai\Winapp3.cpp cannot convert `HWND__*' to `HINSTANCE__*' for argument `11' to `HWND__* CreateWindowExA(DWORD, const CHAR*, const CHAR*, DWORD, int, int, int, int, HWND__*, HMENU__*, HINSTANCE__*, void*)' . > > I have worked with C programs under DOS but not under windows, so I am unable to understand what it means and what rectification is needed in the program. > > And also can someone suggest me some books/websites from where I can learn C under windows efficiently. > > > Regards > Sudipta Lal Basu > > Student, M.Tech (Structural Engineering) > G-51, Jawahar Bhawan > IIT Roorkee > Ph-9897509977 > > Send instant messages to your online friends http://uk.messenger.yahoo.com > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > -- Fernando Lichtschein li...@fi... |
From: Per W. <pw...@ia...> - 2006-08-21 16:00:40
|
I don't know what you did expect. First of all, there are no standard that tells how muh extra data that a compiler should/may add to the size of an object. Extra data is needed for RTTI, virtual methods etc. One other important factor is the avoidance of zero-size objects. Let's say that you have an object of zero size. Then you allocate an array of 100 such objects. How would you now iterate through the array? If the object has zero size, each element of the array would have the same address since the whole array would be zero size. /Per W On Mon, 21 Aug 2006, karunakar A.K. wrote: > Dear All > > Output of the following program is 1. Please explain me the reason. > > > with regards > karunakar > > > > > #include <iostream.h> > #include <conio.h> > > class Object > { > public: > Object() { } > }; > void main() > { > cout << "\nSize = " << sizeof(Object); > } > > > --------------------------------- > Here's a new way to find what you're looking for - Yahoo! Answers > Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it NOW |