|
SWDevil wrote: void func(int A, int B, int C, int D=-1, int E=-1, F);
forget about calling the funtion, C++ won't allow to declare the funtion like this.
If you declare an argumnet with default value then all the arguments after that should have default value .
Regards
Anil
|
|
|
|
|
oops - my mistake...
I meant to declare the function:
void func(int A, int B, int C, int D=-1, int E=-1, F=-1);
but if I declare it this way, will I be able to call the func without specifying the parameters D and E?
|
|
|
|
|
Nope. You have to provide the arguments in the same order. Whenever you supply a value for an optional parameter, it will be used for the first optional parameter.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
SWDevil wrote: but if I declare it this way, will I be able to call the func without specifying the parameters D and E?
Well if you are desperate to get it working take a look at va_arg , va_list , va_start , va_end . It's an option.
Owner drawn
Jesus Loves
|
|
|
|
|
Owner drawn wrote:
Well if you are desperate to get it working take a look at va_arg, va_list, va_start, va_end. It's an option.
Well Back after long time
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Where are you buddy? These days you are not posting messages to the board.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
brahmma wrote: Where are you buddy? These days you are not posting messages to the board.
Hmm.. I was away for quite a while but now alive and kicking.
Owner drawn
Jesus Loves
|
|
|
|
|
No you can't
What you want is calling the function
void func(int A, int B, int C, int D=-1, int E=-1, F=-1);
in func(A,B,C,,,F);
Suppose( which will never happen)if you succeed, you will get D and E as -1.
So you can call
func(A, B, C, -1, -1, F); :-)
Regards
Anil
|
|
|
|
|
why not putting the F parameter between C and D ?
void foo(int A, int B, int C, int F = -1, int D = -1, int E = -1) {
}
so that you can use it like this :
int A, B, C, D, E, F;
foo(A, B, C);
foo(A, B, C, F);
foo(A, B, C, F, D);
foo(A, B, C, F, D, E);
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
But I also sometimes want to call the function without the F parameter (and with the D and E parameters)...
|
|
|
|
|
|
SWDevil wrote: ut I also sometimes want to call the function without the F parameter (and with the D and E parameters)..
What about using Variable Argument System!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi,
the simples solution is to provide a wrapper macro for your function
void func(int A, int B, int C, int D=-1, int E=-1, int F=-1);
#define FUNC(a_, b_, c_, f_) func(a_, b_, c_, -1, -1, f_)
This way you can simply call it through the macro in those rare occasions where only the F should be given.
void Call()
{
int A, B, C, D, E, F;
func(A, B, C);
func(A, B, C, D, E, F);
FUNC(A, B, C, F);
}
codito ergo sum
|
|
|
|
|
I have an Edit Control created using WINAPI in a COM component which is called by an Outlook Addin. Now whenever I want to retrieve the text on the Edit Control using GetWindowText , I don't get anything? Also, when I try to use SendMessage using WM_GETTEXT , I get an Unhandled Exception in Outlook.EXE(USER32.dll) 0xC0000005:Access Violation error. Can anyone explain why this happens?
SetWindowText works fine and so does the other APIs. The Edit Control is not a multiline Edit Control.
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
-- modified at 2:19 Wednesday 31st May, 2006
|
|
|
|
|
Are you sending the WM_GETTEXT message between processes?
Steve
|
|
|
|
|
Stephen Hewitt wrote: Are you sending the WM_GETTEXT message between processes?
Nope. I have created the Edit Control in the COM component which runs under the same process as outlook does. A peculiar behavior is that, when the Edit control has focus and I press the Backspace key, the Backspace key gets transferred to Outlook and it is outlook that reacts to the Edit key, not the Edit control. Can you explain this peculiar behavior or the scenarios when this happens?
Thanks for replying.
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Stephen Hewitt wrote: Are you sending the WM_GETTEXT message between processes?
Usually People use this Message to reterive text from other UI
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Yeah, but the scenario I enquired about could explain the crash which is why I asked: the address in LPARAM is only valid within the sending process.
Steve
|
|
|
|
|
I think, u r trying 2 use a pointer with out allocating it.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
Can you show your code that has error
whitesky
|
|
|
|
|
NiceNaiduI think, u r trying 2 use a pointer with out allocating it.
Nope. I don't think so!
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
my answer now your answer 17 min ago
whitesky
|
|
|
|
|
TechyMaila wrote: Nope. I don't think so!
Could you show me your Code of SendMessage ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I have error while using SetWaitableTimer on IA64 machine. What could be the solution? IS there any alternative for that API? Or do I need to change any settings?
Prashant Joshi
|
|
|
|
|
Check this Sample from MSDN
#define _WIN32_WINNT 0x0500<br />
<br />
#include <windows.h><br />
#include <stdio.h><br />
<br />
int main()<br />
{<br />
HANDLE hTimer = NULL;<br />
LARGE_INTEGER liDueTime;<br />
<br />
liDueTime.QuadPart=-100000000;<br />
<br />
hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer");<br />
if (!hTimer)<br />
{<br />
printf("CreateWaitableTimer failed (%d)\n", GetLastError());<br />
return 1;<br />
}<br />
<br />
printf("Waiting for 10 seconds...\n");<br />
<br />
if (!SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, 0))<br />
{<br />
printf("SetWaitableTimer failed (%d)\n", GetLastError());<br />
return 2;<br />
}<br />
<br />
<br />
if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0)<br />
printf("WaitForSingleObject failed (%d)\n", GetLastError());<br />
else printf("Timer was signaled.\n");<br />
<br />
return 0;<br />
}
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|