|
Rob Caldecott wrote: Which of the abiove you use? Any solid reasons why? Also, in the case of a string, would you explicitly initialize it to an empty string (str_("")) or call the strings default constructor (str_())?
Since str_("") doesn't serve any better purpose that str_() I would go for str_(). Since a good default constructor will set it's member elements to a predefined state. This should suffice.
|
|
|
|
|
calling str_() would save on having to pass a parameter. (not much of a difference, just me being picky).
|
|
|
|
|
Rob Caldecott wrote: For example, suppose you have a class that contains a std::string (or CString), and the strings should be empty ("") when the class is created. I have always let the compiler implicitly call the string constructor, and hence would have something that looks like this:
class foo{private: std::string str_;public: foo() /* str_ constructor implicitly called */ { }};
you are right.
Rob Caldecott wrote: However, it has been suggested that all members should appear in the constructors initialization list, and that I should change my constructor to one of the following:
foo() : str_("")
or
foo() : str_()
In this case it doesn't make sense to initialize member variable in initialization list. Because, generally, well designed classes takes care of default initialization.
Only difference, here would hapeen is, if you doesn't use member initialization list, default c'tor will be called, and copy c'tor otherwise.
It is advised to use member initialization list, because it save assignment operator call; if you are going to assign some value to member variable.
consider this scenario,
class foo
{
CStrin m_sMyString;
public:
foo()
{
m_sMyString = "This string i want as default";
}
}; where as this is efficient,
class foo
{
CStrin m_sMyString;
public:
foo(): m_sMyString("This string i want as default")
{
}
};
|
|
|
|
|
See member initialization list for more.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
OK - the order of initialization is important, etc. but I am still unsure whether it is good practice to initialize all members, even those (like strings for example), that already have default constructors that can be called implicitly. What do you do in your code for example? Do you initialize everything or just POD types?
Kicking squealing Gucci little piggy.
|
|
|
|
|
Rob Caldecott wrote: Do you initialize everything or just POD types?
Only those that I know for sure don't have their own initialization.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Hello,
I work in MFC project that use a MSDATGRD.OCX control (DataGrid). It works well but I can not set the with for each colunm that mean I have a function "SizeColWith(20)" but it change all colunm with!
How can I acces the properties for each colunm.
Than you
AutreChien
|
|
|
|
|
I have a html page. I load to VC6 Dialog.
I want to make some button that call the link on html page.
How can i make it?
|
|
|
|
|
tamasan wrote: I have a html page. I load to VC6 Dialog.
How are you loading the HTML page in your dialog?
tamasan wrote: want to make some button that call the link on html page.
Do you want to open the link in a browser window on button click?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I think you need to say more explain but if you want to show html files on dialog you can use CDHtmlDialog
|
|
|
|
|
|
If you have a function that it supports html document now what prolem?
|
|
|
|
|
::ShellExecute(NULL, "open", "http://the_url.htm", NULL, NULL, SW_SHOW);
|
|
|
|
|
1)In my application im calling this function
::FtpCommand(hConnect, // WinInet Connection handle
FALSE, // No, I don't expect a response
FTP_TRANSFER_TYPE_BINARY, // I'm receiving ASCII
strSeekOffsetCMD.c_str(), // This is the FTP command I am passing
0, // No context needed
&hResponse); // The handle to read the response
But im getting error like this......
C:\Documents and Settings\Administrator\Desktop\pr\PauseResumeDemoDlg.cpp(311) : error C2039: 'FtpCommand' : is not a member of '`global namespace''
C:\Documents and Settings\Administrator\Desktop\pr\PauseResumeDemoDlg.cpp(311) : error C2065: 'FtpCommand' : undeclared identifier
Error executing cl.exe.
this FtpCommand has to be declared in WinInet.h.................but in VC98
it is not defined how can i solve this issue .....................
|
|
|
|
|
codepanter wrote: is not a member of '`global namespace''
Remove :: and put is as FtpCommand(/*parameters*/)
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Are you using the correct platform SDK? Have you looked in wininet.h to make sure the functon's signature is there?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I have a CDialog class CRTLDialogDlg which derives from CDialog and CDialogTemplate. I need to change the Dialog template of my dialog to support Hebrew. I Override the DoModal of CRtlDialogDlg and write the following code :
INT_PTR CRTLDialogDlg::DoModal()
{
CRTLDialogDlg *pDlg = (CRTLDialogDlg*)this;
int nResult;
HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(CRTLDialogDlg::IDD), RT_DIALOG);
if (hInst == NULL)
return FALSE;
HRSRC hRsrc = FindResource(hInst, MAKEINTRESOURCE(CRTLDialogDlg::IDD), RT_DIALOG);
if (hRsrc == NULL)
return FALSE;
HGLOBAL hTemplate = LoadResource(hInst, hRsrc);
DLGTEMPLATE* pTemplate = (DLGTEMPLATE*)LockResource(hTemplate);
pTemplate->dwExtendedStyle |= WS_EX_LAYOUTRTL;
SetTemplate(pTemplate, (UINT)SizeofResource(hInst, hRsrc));
UnlockResource(hTemplate);
FreeResource(hTemplate);
//// get pointer to the modified dialog template
LPSTR pdata = (LPSTR)GlobalLock(pDlg->m_hTemplate);
//// let MFC know that you are using your own template
m_lpszTemplateName = NULL;
InitModalIndirect(pdata);
//// display dialog box
nResult = CDialog::DoModal();
//// unlock memory object
GlobalUnlock(pDlg->m_hTemplate);
return nResult;
}
But this does not do anything at all. Where have I gone wrong? It works perfectly if I change the .rc file but I dont want to make any changes in the .rc File.
Reji Kumar,
Software Engineer,
India.
|
|
|
|
|
Hi,
Why dont you use the Create method for choosing a template at runtime?
Mohmmad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Could you tell me how to do it using Create? My basic requirement is to bring up a Modal dialog box with all controls rightaligned to support RTL languages.
Reji Kumar,
Software Engineer,
India.
|
|
|
|
|
Dear all
during an image show i would like to use other menus.but for now in my sytem, during show image, i can't use other menus.that means i can't click other menus. how to use mouse function to realize this? thank u
Li Zhiyuan
5/10/2006
|
|
|
|
|
How do you show your image and why you cant use from menus?
|
|
|
|
|
I have to set MIME type of IIS from VC++ application using COM interface.
Pls share code or information
Thanks
Anil
|
|
|
|
|
|
Hi,
I need a code to send mail thru VB with out opening
Outlook or Outlook xpress (The mail sending should
not transparent to users). post code snippet
ASAP.
You only have to do a very few things right in your life so long as you don't do too many things wrong.
Vivek.S
|
|
|
|