|
You can also look here[^], these list control can have any control in any column ...
modified 16-Jun-12 5:16am.
|
|
|
|
|
Hi all,
I'll try to explain my question as much as quickly. Actually its not a question, but a clarification I am looking for.
Say I have a two code blocks which is doing two different things. I can implement those two blocks in two functions and call as I need from a third function. Or else, I can implement those two blocks in the third function and used goto jump between blocks. So what is the difference between two?
Thanks for all the comments in advance.
If you've never failed... You've never lived...
|
|
|
|
|
// So what is the difference between two?
I would say
- stack
- accountability for the heap (de-)allocations
- perfomance
- re-usage of the functions
- readability
What thesis does stay misty for you ?
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
A goto wont add stuff to the stack like a function call will.
But the problem is that the code that you goto has to get back somehow, which means embedding a label in your code, which means you goto code would be better just put in your calling code. So really, you should use a func, it will be easier.
Gotos are useful for exiting funcs in error conditions. (Often replaced by a do{}while(0) these days).
==============================
Nothing to say.
|
|
|
|
|
People will hate you if you use goto , it makes the code more difficult to test, debug and maintain; stick with functions.
|
|
|
|
|
This is pure dogma. Any code can be crap and hard to maintain and goto when used judiciously is perfectly OK.
For example:
myfunc()
{
do{
if(!somefunc())
continue;
if(!someotherfunc())
continue;
}while(0);
}
Is heavy when compared to:
myfunc()
{
if(!somefunc())
goto end;
if(!someotherfunc())
goto end;
end:
}
==============================
Nothing to say.
|
|
|
|
|
Erudite_Eric wrote: This is pure dogma.
Not at all. And what's wrong with:
myfunc()
{
if(somefunc() &&
someotherfunc())
{
}
}
|
|
|
|
|
I think I have found a bug in the CString assignement operator of the ATL/MFC 8.
CStringT& operator=( __in_z_opt PCYSTR pszSrc )
The method calculates the length of the required buffer and allocates the buffer. The calculation does not include the terminating null character. Thereafter it calls MultiByteToWideChar, passing the length as the cchWideChar parameter.
The function MultiByteToWideChar returns 0 as failure indication, but this is ignored by the MFC. As a side effect, MultiByteToWideChar fills the output buffer on some platforms like Win32 and Windows CE 5.0 (SH4).
But the Windows CE 5.0 (x86) implementation of MultiByteToWideChar does not fill the buffer. Although the allocated buffer is too small, the bug is not visible on most platforms but on Windows CE 5.0 (x86). Here you get an empty CString after the assignment.
Example:
CStringW s("ABC");
PCWSTR p = (PCWSTR)s;
assert(0 != p[0]); The assert in the code above fails.
|
|
|
|
|
It wont be the first time different platforms have behaved differently. Whether MS will admit its a bug or not, well, they dont like to.
But anyway, contact them and see what they say. There might be a patch already.
==============================
Nothing to say.
|
|
|
|
|
Here is an polar example of the operator's usage :
{
LPTSTR lpszBuffer(_T("test"));
CString cszDestination;
cszDestination = lpszBuffer; ASSERT(cszDestination[0] == _T('t'));
}
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
Yes, this calls the assignment constructor directly. It shows the same behavior since it executes the same code.
My example came from a real project.
As long Microsoft is reluctant to fix this I will have to get the debug source code and build my own MFC version. Unfortunately this requires to install this version on all PCs that just wants to assign an (ANSI) string to a string class object.
|
|
|
|
|
class Filter;
typedef void (Filter::*PFN)();
class Filter
{
public:
void ProcessPart();
void MyProcessPart();
struct Pair_t
{
Pair_t(int d, PFN n) : iid(d), pfn(n) {}
int iid;
PFN pfn;
private:
Pair_t& operator=(const Pair_t&);
};
};
void Filter::ProcessPart()
{
PFN pfn2;
pfn2 = dynamic_cast<Filter*> (&Filter::ProcessPart);
Pair_t(9, pfn2);
}
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
I am not able to solve this.
Any help?
Thanks
|
|
|
|
|
You are trying to cast a function address to a pointer to a class, which is illegal.
|
|
|
|
|
Ya I got it.
Thanks Richard MacCutchan
|
|
|
|
|
Function pointer casting has a really crappy syntax in C. I posted on it way back, but so ugly is I have totally forgotten how it goes.
==============================
Nothing to say.
|
|
|
|
|
You've already had help from the clever people here, but it would have helped them if you'd put the error in the posting too.
If you make it easy to help you, more people will try.
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
Iain Clarke, Warrior Programmer wrote: if you'd put the error in the posting too.
Ahem, it's in the original question, as a C++ comment.
|
|
|
|
|
OK, I'll partially let him off then!
But pasting the whole error message is still wise. Do *you* remember E1234 off by heart?
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
Iain Clarke, Warrior Programmer wrote: But pasting the whole error message is still wise.
I agree entirely.
Iain Clarke, Warrior Programmer wrote: Do *you* remember E1234 off by heart?
No, but I can spell MSDN and even Google.
|
|
|
|
|
Hi
I've been struggling for some time to create a sample app in C++ that can upload and download to/from Google Docs using their 'Resumable Upload API'.
I've got quite a long way using Google's own documentation to implement a REST solution but there is so little example code that when I hit a stumbling block there is nowhere to turn.
Firstly, do you have specific experience with Google Docs?
Secondly, would you be willing to offer some specific feedback on my code?
|
|
|
|
|
Usually things like Google apps (apps or libraries) tend to have forums for their users to interact and ask questions, have you looked to see if such forum exists? You may have better luck with people who have used that specific API there.
|
|
|
|
|
Thx Albert.
I have already tried the Google forums but I'll give them another try.
|
|
|
|
|
Hello,
I have a multi threaded MFC exe built with all its basic classes including CSocket, with TCP connection through mainframe etc. , I want to split it to two different components. ATL service and MFC GUI. Can I do it and can I use the MFC classes in the ATL service.
Thanks in advance,
Eyal
|
|
|
|
|
hello guys... Is it possible to encrypt voice just like we can encrypt data. Encryption methodology can be any like: reversing the voice. For example, If I speak hello then I want it to be converted to olleh . Thnx
This world is going to explode due to international politics, SOON.
|
|
|
|
|
You can encrypt any bit stream using the various libraries available for the purpose. To do what you are asking would require analysis of the stream and separation at each character of each word, which is impossible in spoken sounds.
Try saying "hello" with different stresses and see if you can determine the exact point where each letter starts and ends; do you hear one or two 'l's?
|
|
|
|