|
what is the diffrence between
return (SUCCESS) and return SUCCESS. And
Delete (this) and Delete this;
is it Only syntactic diffrence or any significent difference in it?
Guide me ?
krishna
|
|
|
|
|
It is just syntaxic difference. It is like in calculation:
1 + 1 is the same as
(1) + (1) and the same as
(1 + 1)
Sometimes it is needed to put '( )' but when it is not needed, there is no difference.
Or at least, no of what I'm aware of
|
|
|
|
|
|
1) Personally, I used to see some old pure C code in this way:
return (value);
And most pure C++ code in this way:
return value;
2) Another viewpoint, comparing with the casting, but I am not sure if there any relation between casting and return:
C and C++ allow either way to do casting:
(int)value
and
int(value)
3) One convenience to do return (value) would be:
You would feel safe to do more operations like:
return (value *2 +3);
Maxwell Chen
|
|
|
|
|
one precision Maxwell :
(int)value and int(value) are quite different.
(int) calls actually the overloaded int cast operator on the existing instance.
int() creates a new int instance calling the int copy constructor.
|
|
|
|
|
v2.0 wrote: (int)value and int(value) are quite different.
But, if the case that value is just of the built-in value types like char instead of class / struct / union types?
I am using VC++ 2003 now, and I tested the code just now:
char a;<br />
int b;<br />
b = int(a);<br />
b = (int)a;<br />
As indicated in the disassembly, they are the same as below:
char a;
int b;
b = (int)a;
0041F6BA cmp byte ptr [ebp-0E9h],0
0041F6C1 jne OnBnClicked+40h (41F6D0h)
0041F6C3 push 41F708h
0041F6C8 call @ILT+2635(__RTC_UninitUse) (419A50h)
0041F6CD add esp,4
0041F6D0 movsx eax,byte ptr [a]
0041F6D4 mov dword ptr [b],eax
b = int(a);
0041F6D7 cmp byte ptr [ebp-0E9h],0
0041F6DE jne OnBnClicked+5Dh (41F6EDh)
0041F6E0 push 41F708h
0041F6E5 call @ILT+2635(__RTC_UninitUse) (419A50h)
0041F6EA add esp,4
0041F6ED movsx eax,byte ptr [a]
0041F6F1 mov dword ptr [b],eax
Maxwell Chen
|
|
|
|
|
v2.0 wrote: int() creates a new int instance calling the int copy constructor.
int is an integral type, not a class. How can it have a constructor, or even a method?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
even intregral types can be considered - due to the fact that C++ is an OO language - like a class... of course, there are restrictions to this, but int() and (int) are not identical in theory...
|
|
|
|
|
v2.0 wrote: even intregral types can be considered...like a class
How so, and why would you want to? No OO-specific topics relate to them (e.g., they can't be inherited from).
v2.0 wrote: ...but int() and (int) are not identical in theory...
Which implies they are identical in practice. Yes?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: No OO-specific topics relate to them (e.g., they can't be inherited from).
i said there were limitation, not that all OO topics were applying.
DavidCrow wrote: Which implies they are identical in practice. Yes?
hum, looking at the assembler generated, i must agree that both are identical for the processor, but i still believe that it remains a compiler specificity
|
|
|
|
|
Page 70,
$ 5.2.3 Explicit type Conversion
1. A simple-type-specifier (7.1.5) followed by a parenthesized expression-list constructs a value of the specified type given the expression list. If the expression list is a single expression, the type conversion expression is equivalent (in definedness, and if defined in meaning) to the corresponding cast expression (5.4). If the simple-type-specifier specifies a class type, the class type shall be complete. If the expression list specifies more than a single value, the type shall be a class with a suitably declared constructor (8.5, 12.1), and the expression T(x1, x2, ...) is equivalent in effect to the declaration T t(x1, x2, ...); for some invented temporary variable t, with the result being the value of t as an rvalue.
Maxwell Chen
|
|
|
|
|
ok, thanks Maxwell, that's more clear now.
|
|
|
|
|
Sometimes I need to display a bitmap much smaller then its original size, by using the StretchBlt API I get sadly ugly outcomes, I've noticed many picture-viewer applications have the ability of stretch-displaying pictures while maintaining high quality, some of them(IE 6.0, etc) can even do that job absolutely perfect. I wonder if I too can implement that in my own projects? Any help are appreciated.
|
|
|
|
|
for starters, see SetStretchBltMode
if that doesn't do it, you'll need to explore the world of image resizing algorithms and resize the image yourself. i hear there are toolkits out there to help with this.
=[ Abin ]= wrote: some of them(IE 6.0, etc) can even do that job absolutely perfect
no method is perfect. the best you can hope for, especially when enlarging, is adequate.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
i want to create a button which actully create in DLL and set in my dialog(which is executable)
how it is possible.
Bankey Khandelwal
Software Engineer
|
|
|
|
|
Use MFC Extended DLL.
Fly Like An Eagle With MIGHTY POWER.
|
|
|
|
|
Hi,
I have a custom combobox derived from CWnd.
I want to use this control with DDX_Control.
The combobox have a child control member m_Edit (CEdit).
Where can i call the m_Edit Create function?
|
|
|
|
|
Hi zuma77,
Do you need to insert Edit to Combobox?
|
|
|
|
|
Hi WhiteSky,
No, the Combobox have an Edit (if the style isn't CBS_DROPDOWNLIST),
and a dropdown list.
I call the Edit Create in the OnCreate of the Combobox,
but if i use DDX_Control to create Combobox, than the OnCreate function
in not called.
Where can i call the the edit create function in this case?
|
|
|
|
|
zuma77
Hope I understood your question
I see you use DDX_Control then (I think)you can't use Oncreate for create edit
I suggestion(Im not sure that is very good) you enter your code in the
function in classs derived(ccombobox) but with one if (if m_Eidt.m_hwnd==NULL then create)
|
|
|
|
|
Thanks for your help.
The PreSubclassWindow function was the key.
|
|
|
|
|
DDX_Control calls SubclassDlgItem for an existing control. In this case, the control has already been created. You will need to locate and subclass the edit control.
Software Zen: delete this;
|
|
|
|
|
Thanks for your help.
It works now
|
|
|
|
|
Hi,
How to simulate DoEvents() function of Visual Basic in Visual C++? Please help if you know.
|
|
|
|
|
Something might work
void DoEvents()<br />
{<br />
MSG dispatch;<br />
while (::PeekMessage( &dispatch, NULL, 0, 0, PM_NOREMOVE))<br />
{<br />
if (!AfxGetThread()->PumpMessage());<br />
}<br />
}
|
|
|
|