|
was asked in an interview --->
1. If the default constructor fails what happens?
2. What is Conversion constructor? Please give a small code example.
3. Why there is no virtual constructor?
thanx in advance
kumar_windows
|
|
|
|
|
1. Fails? In what way? If an exception is thrown, it's the same as if any other exception is thrown. The object is left in an undefined state, and should not be used.
2. A constructor that can be used to convert between different types. It takes one argument, and allows you to typecast from the argument type to the class type.
3. Because when you create a class, the compiler has to know exactly what type it is. The virtual function pointer table is initialised as part of the constructor call, so there is no way to implement a virtual function lookup until after the constructor completes.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
kumar_windows wrote: If the default constructor fails what happens?
http://burks.bton.ac.uk/burks/language/cpp/cppfaq/exceptio.htm#[17.1][^]
kumar_windows wrote: 2. What is Conversion constructor? Please give a small code example.
A constructor that accepts one argument of a different type
For e.g
CDemo d{
int m_i;
public:
CDemo(int i){
m_i=i;
}
}; kumar_windows wrote: Why there is no virtual constructor?
There is nothing like Virtual Constructor.
The Constructor can’t be virtual as the constructor is a code which is responsible for creating a instance of a class and it can’t be delegated to any other object by virtual keyword means.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
hi all
i have got a problem like i want to get the dpi which is set in the XP
inside the code like 96dpi or 120 dpi like that,but i am not finding any way.
if any of u know about it please tell me .
"Men never do evil so completely and cheerfully as when they do it from religious conviction"
-Pascal
|
|
|
|
|
I think EnumDisplaySettings() can help you.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Create a device context for the screen (GetDC(NULL) ) and call GetDeviceCaps() on it, specifying the LOGPIXELSX or LOGPIXELSY codes.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Is it true that if I post a request for receving (WSARecv/WSA_IO_PENDING),
then just wait on GetQueuedCompletionStatus for the completion until any client send some data and the receiving is finished?
|
|
|
|
|
With IOCP, you don't wait on anything (at least not in the form of a blocking call or anything like that) as the commands return immediately.
You post your commands such as WSASend and WSARecv and your worker thread(s) get called with the CompletionPortID when they complete. Thats when you call GetQueuedCompletionStatus() and process your data buffers and then issue a new command and such. Your thread(s) should never block with IOCP but if one does, the other remaining thread(s) will pick up the slack.
It's really beautiful in concept though I've never quite gotten my multithreading skills honed enough to fully appreciate it under heavy load without some form of thread lockup issues. There are a few good articles on it here at CP. There was a Win2000 system programming book (now out of print) by Jeffery Richter and Jason Clark titled "Programming Server-Side Applications for Microsoft Windows 2000
" that has some pretty good information on them in general.
|
|
|
|
|
Hey all,
I have created a dialog page using CFormview class. I 've created group boxes and added control buttons like static/edit boxes as my application needs in them. But aftersome inclusions,say, after 150 or so control button creations, I could no longer add any more control buttons ( not editboxes or anythingelse..)I tried debugging by starting from the scratch ( thinking that my file would have gone corrupt due to some reason) again using new application. but encountered the same problem. What could be wrong? CAn anyone guide me please?
|
|
|
|
|
aannuu wrote: But aftersome inclusions,say, after 150 or so control button creations, I could no longer add any more control buttons ( not editboxes or anythingelse..)
Why so many control in a form view? I guess there is a limit on the number of controls that you can have in a formview/dialog.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
I thought so...but do u know that limit.???....how many can i use in a dialog page. bcoz my application needs so many controls.
In that case, I may have to create different dialogpages and then add controls.
|
|
|
|
|
The Visual C++ dialog editor has a limit of 256 controls on a form view or dialog box. You can create more than that by creating them at runtime, although if you've got that many, I'd suggest that your form is a bit cluttered and it might be better to break it into multiple forms.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
yse i see this problem well you can create controls dynamic
whitesky
|
|
|
|
|
Can one of you please post frequently asked Interview questions (with answers) for Multithreaded programming in C++/VC++
Thanks in advance!
|
|
|
|
|
15.Types of threads?
A.) There are 2 types of threads they are 1.) Worker threads (doesn’t have a message pump) —-> usually used for background processing like searching etc.
2.User Interface Thread(which has a message pump) can be used to create windows.
16.Is it possible to share the thread stack memory to another threadNO
17.Types of Syncronization Classes?
A.) CMutex, CSemaphore, CCriticalSection, CEvent
7.What is Serialization? Which macro is to be specified in the user-defined class, which will take part in serialization?
A.) Serialization is the process of writing or reading the contents of an object to and from a file. Include the macros DECLARE_SERIAL in the .h file
IMPLEMENT_SERIAL in the .cpp file
7. What are the parameters passed for IsLoading() and IsStoring() functions?
A.) No parameters are passed to both the functions.
6. What do u mean by the third parameter in IMPLEMENT_SERIALIZE?
A.) IMPLEMENT_SERIAL(class_name, base_class_name, wSchema);
The 3rd parameter is wSchema A UINT “version number” that will be encoded in the archive to enable a deserializing program to identify and handle data created by earlier program versions. The class schema number must not be –1.
• Base class of all the threads --> CWinThread
regards
kumar_windows
|
|
|
|
|
Thanks for your help Kumar!
Today I got some new things to learn!
|
|
|
|
|
|
Thanks for your timely help Laxman!
|
|
|
|
|
Hi
I am currently writting an installer for my project.
Instead of writting uninstaller I want to use the windows add and remove program to do it. How can I add my install informations in the "Add and remove program" list. Can you please give me some hint so that I can have a try.
Thanks
Regards
Anil
|
|
|
|
|
I am trying to use the EnumDisplayDevices function, but for some reason is giving me a undeclared Identifier:
#include <windows.h>
#include <iostream>
using namespace std;
void main()
{
DISPLAY_DEVICE dd;
DWORD i;
ZeroMemory(&dd, sizeof(dd));
dd.cb = sizeof(dd);
for(i=0; EnumDisplayDevices(NULL, i, &dd, 0); i++)
{
cout<
|
|
|
|
|
Hi
Though I can't exactly tell why the problem is occoring some of the resons are
UNICODE and WINVER definations. If you go to winuser.h you can see the defination of EnumDisplayDevice.
you can try as MSDN way. that is dynamically loding the funtion from DLL.
<br />
BOOL GetDisplayMonitorInfo(int nDeviceIndex, LPSTR lpszMonitorInfo)<br />
{<br />
FARPROC EnumDisplayDevices;<br />
HINSTANCE hInstUser32;<br />
DISPLAY_DEVICE DispDev; <br />
char szSaveDeviceName[32];<br />
BOOL bRet = TRUE;<br />
<br />
hInstUser32 = LoadLibrary("User32.DLL");<br />
if (!hInstUser32) return FALSE; <br />
<br />
EnumDisplayDevices = (FARPROC)GetProcAddress(hInstUser32,"EnumDisplayDevicesA");<br />
if (!EnumDisplayDevices) {<br />
FreeLibrary(hInstUser32);<br />
return FALSE;<br />
}<br />
<br />
ZeroMemory(&DispDev, sizeof(DISPLAY_DEVICE));<br />
DispDev.cb = sizeof(DISPLAY_DEVICE); <br />
<br />
if (EnumDisplayDevices(NULL, nDeviceIndex, &DispDev, 0)) { <br />
lstrcpy(szSaveDeviceName, DispDev.DeviceName);<br />
<br />
EnumDisplayDevices(szSaveDeviceName, 0, &DispDev, 0); <br />
<br />
lstrcpy(lpszMonitorInfo, DispDev.DeviceString);<br />
} else {<br />
bRet = FALSE;<br />
}<br />
<br />
FreeLibrary(hInstUser32);<br />
<br />
return bRet;<br />
}<br />
<br />
Regards
Anil
|
|
|
|
|
Anil, Thank for your help, but this thing is starting to get on my nerves. I can not get it to work.
I try the above and nothing, then I try to simplify it and another error, see:
#include <windows.h>
BOOL GetDisplayMonitorInfo(int nDeviceIndex, LPSTR lpszMonitorInfo)
{
FARPROC EnumDisplayDevices;
HINSTANCE hInstUser32;
DISPLAY_DEVICE DispDev;
char szSaveDeviceName[32];
BOOL bRet = TRUE;
hInstUser32 = LoadLibrary("User32.DLL");
if (!hInstUser32) return FALSE;
// Get the address of the EnumDisplayDevices function
EnumDisplayDevices = (FARPROC)GetProcAddress(hInstUser32,"EnumDisplayDevicesA");
ZeroMemory(&DispDev, sizeof(DISPLAY_DEVICE));
DispDev.cb = sizeof(DISPLAY_DEVICE);
EnumDisplayDevices(szSaveDeviceName, 0, &DispDev, 0);
FreeLibrary(hInstUser32);
return bRet;
}
void main()
{
}
The error I get is:
error C2197: 'int (__stdcall *)(void)' : too many actual parameters on EnumDisplayDevices(szSave....)
I am thinking, I will not trying to get this function to work.
|
|
|
|
|
Anil, sorry for the above that says
#include it is missing <windows.h>
|
|
|
|
|
SOrry I did not know that this was taking HTML tags,
so the <> does not come out.
anyway it is #include <windows.h>
|
|
|
|
|
I have just copy and paste the above code from MSDN
any way this time I changed it in my way and comiled it. Hope it will work.
<br />
<br />
typedef BOOL (WINAPI* EnumDisplayDevices) (<br />
LPCTSTR lpDevice,
DWORD iDevNum,
PDISPLAY_DEVICE lpDisplayDevice,
DWORD dwFlags
);<br />
<br />
BOOL GetDisplayMonitorInfo(int nDeviceIndex, LPSTR lpszMonitorInfo)<br />
{<br />
EnumDisplayDevices pEnumDisplayDevices;<br />
HINSTANCE hInstUser32;<br />
DISPLAY_DEVICE DispDev;<br />
char szSaveDeviceName[32];<br />
BOOL bRet = TRUE;<br />
<br />
hInstUser32 = LoadLibrary("User32.DLL");<br />
if (!hInstUser32) return FALSE;<br />
<br />
pEnumDisplayDevices = (EnumDisplayDevices)GetProcAddress(hInstUser32,"EnumDisplayDevicesA");<br />
<br />
ZeroMemory(&DispDev, sizeof(DISPLAY_DEVICE));<br />
DispDev.cb = sizeof(DISPLAY_DEVICE);<br />
<br />
pEnumDisplayDevices(szSaveDeviceName, 0, &DispDev, 0);<br />
<br />
FreeLibrary(hInstUser32);<br />
<br />
return bRet;<br />
}<br />
<br />
<br />
void main()<br />
{<br />
}<br />
<br />
Regards
Anil
-- modified at 21:05 Tuesday 23rd May, 2006
|
|
|
|