|
hawkgao0129 wrote: ADL finds operator+ in CStringT
No. The CStringT operator+ is not visible (so is not found). ADL doesn't come into play because you've declared TestString within the global namespace.
In addition, (I may have mis-stated this earlier) ADL won't find the operator+ in CStringT even if you did put TestString in the ATL namespace because it's a friend function defined in class scope, so is only visible to parameters of type CStringT.
As I said - C++ name lookup rules are very complex - so I apologise for making some slight mistakes in explanation (but remain unsurprised that I did so ).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Do you notice the error message in my first post. Compiler seems have found the operator+ in CStringT and CStringT's parent class.
1>c:\build\test\test\test.cpp(19) : error C3767: '+': candidate function(s) not accessible
1> could be the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(653)' : '+' [may be found via argument-dependent lookup]
...
And, Is my statement about "t1+(CString)t2" right?
modified on Wednesday, July 22, 2009 5:31 AM
|
|
|
|
|
I did notice that. Which is why (when I compiled your code), I tried sticking TestString in the ATL namespace (same as CStringT). And it didn't work - but I'm starting to think I got the wrong namespace - I've tried some more experiments that confuse things a little, and seem to indicate that there is at least one bug associated with name lookup in VC.
I wrote this code:
namespace Test
{
class A
{
public:
friend void TestFn(const A&) { }
};
class B
{
public:
operator A(){ return A(); }
};
}
class C
{
public:
operator Test::A(){ return Test::A(); }
};
using namespace Test;
void X()
{
A a;
B b;
C c;
TestFn(a);
TestFn((A)b);
TestFn((A)c);
TestFn(b);
TestFn(c);
}
You can see what I *thought* should happen in the comments. However, VC++ compiles the second last line (TestFn(b); ) instead of raising an error. gcc, on the other hand, conforms exactly to my reading of the standard, compiling the first three function calls but not the last two.
Oh - and the error that VC++ raises for the line TestFn(c); ? It's this:
error C3767: 'TestFn': candidate function(s) not accessible
could be the friend function at 'd.cpp(6)' : 'TestFn' [may be found via argument-dependent lookup]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I'm sending (PostMessage ) from a worker-thread to the main thread a custom message to do some refresh.
What happens is that it looks that a big amount of messages are in some cases accumulated into the list of message.
I don't want to reduce the rate of messages sent.
Is there a simple way when posting [worker-thread] a new message to remove older (obsolete) message (of course the same message type) and leave there only the new one? Or it is possible to tell to the main thread to avoid to process a message if there is in the list the some copy less old than the current one?
Russell
|
|
|
|
|
You can use SendMessageCallback[^] instead of PostMessage .
This API return immediately just like PostMessage .
When the message handler is finished with processing the message the callback function passed in as parameter to SendMessageCallback is called. This way you can keep track of whether a specific message handler has finished processing the message.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I want to disable F12 i.e Save As in word throught automation vc++.
Iam using dsoframectrl,inside this Iam opening word document.Ane need to disable F12.
Please suggest me do accomplish this.
|
|
|
|
|
Hello all,
I m having three different Link-list say apple,mango,banana.
I need to implement common delete function for all the link-list.
Is it possible?
Thank You...
|
|
|
|
|
yes.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
ok, how we can do this? can u explain please?
|
|
|
|
|
One way is to do it using the friend function
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
make the link list a template class say.
class listList<t>
{
}
T can be apple, mango, banana
and override the delete function of the class of list
|
|
|
|
|
Yes, so long as your three linked lists all provide the same interface (and while we're here - if you're not using the standard libraries list template, then why not?).
You can use a template function, like so:
template<class ListType>
void DeleteTheList(ListType& list)
{
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
hi... i have developed MFC (exe) application.but it would run on only those systems where visual studio has installed....how can i use this application on which ever system i want....like the other commercial softwares.... plzzzzzzzzzz help me in that!!!!!
thanks.
|
|
|
|
|
Well you can select the option for "Use MFC in a Static Library", but this would bloat the size of the exe.
On another note, For some applications you may need to have .NET or other dependent framework which you can mention in the prerequisites. Any problem with that?
One more thing, it's not about having VS installed. Installing the framework would suffice.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
actually i m not working in .NET, rather i have developed in VC++6
|
|
|
|
|
you have the option of using MFC in static library in vs6.0
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
ok...thnx... i'll try it.
|
|
|
|
|
MahaKh wrote: i have developed in VC++6
My previous answer assumed you were using a recent compiler version. If you have developed your MFC application with VC6 then you may need to install the Visual C++ 6.0 run-time components on the client computer.
How to obtain the Visual C++ 6.0 run-time components[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Use Dependency Walker[^] to determine the DLLs that your exe is dependent on, then distribute your EXE and those DLLs that aren't on the target machine so they can be copied into the same directory together.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
Check to make sure you are using a Release build instead of a Debug build.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi to all,
I want to store a bigger number in vc++
What is the maximum possible value data structure?...is it long int?
If so please tell me how to check if it has reached the highest value, so that i can restart it from 0
something like
fn()
{
static long int count;
if()///reached maximum value
count = 0;
else
count++;
}
thanks in advance
|
|
|
|
|
If you use an unsigned number (and unsigned __int64 is the biggest you get in VC++), then it'll automatically wraparound to 0 if you try to increment it past its biggest value.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
thanks
-----------------------------
I am a beginner
|
|
|
|
|
if unsigned DWORD64
if signed LONG64
|
|
|
|