Click here to Skip to main content
15,899,475 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dumb Question - Build Large CString Pin
Chuck O'Toole27-Sep-11 10:04
Chuck O'Toole27-Sep-11 10:04 
GeneralRe: Dumb Question - Build Large CString Pin
TheGreatAndPowerfulOz27-Sep-11 10:08
TheGreatAndPowerfulOz27-Sep-11 10:08 
GeneralRe: Dumb Question - Build Large CString Pin
Chuck O'Toole27-Sep-11 10:19
Chuck O'Toole27-Sep-11 10:19 
GeneralRe: Dumb Question - Build Large CString Pin
Stefan_Lang28-Sep-11 1:36
Stefan_Lang28-Sep-11 1:36 
GeneralRe: Dumb Question - Build Large CString Pin
TheGreatAndPowerfulOz28-Sep-11 3:47
TheGreatAndPowerfulOz28-Sep-11 3:47 
GeneralRe: Dumb Question - Build Large CString Pin
Stefan_Lang28-Sep-11 3:51
Stefan_Lang28-Sep-11 3:51 
GeneralRe: Dumb Question - Build Large CString Pin
TheGreatAndPowerfulOz28-Sep-11 6:59
TheGreatAndPowerfulOz28-Sep-11 6:59 
GeneralRe: Dumb Question - Build Large CString Pin
Stefan_Lang28-Sep-11 22:50
Stefan_Lang28-Sep-11 22:50 
ahmed zahmed wrote:
Read my post again.

I did, but I see no misunderstanding on my part. I may not have been clear enough though. All of the things I said above were accurate and I actually checked Visual Studio to make sure they were.

Also anything I 'interpreted' into your posting was accurate - I did not state anything that you didn't say, but you might not have realized the literal meaning of what you were saying. I did not in fact 'interpret' your posting inaccurately, I merely took it literally. I am aware that you did not mean to make (some of) the statements that I read into your posting, therefore I pointed that out to you.

Here's what you said:

ahmed zahmed wrote:
It depends on the definition of CString. If it has a operator+(const char*, const char*)...

First: it does not depend on CString, but more on that later.

Second, when you say that a class X 'has a operator Y(...)', then this might mean that either the operator is defined as a member function, or the operator is defined outside the class. Both are possible, and in fact, the class CString does define all overloads of it's operator+() outside the class, not as member functions. You can indeed find them in the class definition, but only as friend declarations. All 7 overloads are declared friend.

So, when I considered the two possibilities of either a member function operator, or a non-member function, I did not misunderstand your posting, I merely considered two possible meanings.

Third, ...
ahmed zahmed wrote:
Where did I say anything about a tertiary operator +?

... you might not have meant to, but you implied the possibility of an operator
C++
CString& CString::operator+(const char*, const char*)

Now think about that. When you define a member function with two parameters, then in truth, this function has three parameters: the two arguments you specified, plus the instance of the class itself. This instance will be passed to that member function as a pointer, using the name this. Therefore, when you define an operator as a member function and pass it two parameters, the operator will in fact have 3 parameters. An operator with 3 parameters is a ternary operator.


ahmed zahmed wrote:
And CString is NOT a built-in type.


Now you are mistaking me, I did not say that. What I did say was:

Stefan_Lang wrote:
you cannot overload operators working on built-in types

I did not explicitely or implicitely relate to CString here. I did implicitely relate to the (imaginary) simple function const char* operator+(const char*, const char*), not a member function of CString. The arguments that this operator is working on are of type const char*, and that is a built-in type.


Now back to my first point above:
Stefan_Lang wrote:
it does not depend on CString

When you have an expression like this
C++
CString s = "foo" + "bar";

then the compiler evaluates (or at least tries to evaluate) it to
C++
CString::operator=(operator+("foo", "bar"));

Now the compiler has to match all overloads of operator+(,) against the argument types. The argument types in this case are (const char*, const char*). Since neither of the argument types is CString, the compiler can not hope to find one in the list of CString operators! Therefore the implementation of CString is irrelevant in this case!


I hope now my meaning gets clearer.
GeneralRe: Dumb Question - Build Large CString Pin
Snorri Kristjansson4-Oct-11 3:25
professionalSnorri Kristjansson4-Oct-11 3:25 
GeneralRe: Dumb Question - Build Large CString Pin
Chuck O'Toole28-Sep-11 5:18
Chuck O'Toole28-Sep-11 5:18 
GeneralRe: Dumb Question - Build Large CString Pin
TheGreatAndPowerfulOz28-Sep-11 7:08
TheGreatAndPowerfulOz28-Sep-11 7:08 
GeneralRe: Dumb Question - Build Large CString Pin
Chuck O'Toole28-Sep-11 13:31
Chuck O'Toole28-Sep-11 13:31 
GeneralRe: Dumb Question - Build Large CString Pin
jkirkerx28-Sep-11 6:19
professionaljkirkerx28-Sep-11 6:19 
GeneralRe: Dumb Question - Build Large CString Pin
jkirkerx27-Sep-11 10:43
professionaljkirkerx27-Sep-11 10:43 
GeneralRe: Dumb Question - Build Large CString Pin
Code-o-mat27-Sep-11 21:57
Code-o-mat27-Sep-11 21:57 
AnswerRe: Dumb Question - Build Large CString Pin
Chuck O'Toole27-Sep-11 9:55
Chuck O'Toole27-Sep-11 9:55 
GeneralRe: Dumb Question - Build Large CString Pin
Chuck O'Toole27-Sep-11 10:24
Chuck O'Toole27-Sep-11 10:24 
AnswerStrange, the string builds, but the ShellExecuteEX running pkgmgr.exe Pin
jkirkerx27-Sep-11 12:42
professionaljkirkerx27-Sep-11 12:42 
AnswerRe: Dumb Question - Build Large CString Pin
Software_Developer27-Sep-11 18:33
Software_Developer27-Sep-11 18:33 
AnswerRe: Dumb Question - Build Large CString Pin
Stefan_Lang28-Sep-11 1:40
Stefan_Lang28-Sep-11 1:40 
QuestionCalling a function using as your name the content a CString Pin
Samuel Nunes de Arruda27-Sep-11 9:02
Samuel Nunes de Arruda27-Sep-11 9:02 
AnswerRe: Calling a function using as your name the content a CString Pin
André Kraak27-Sep-11 9:12
André Kraak27-Sep-11 9:12 
GeneralRe: Calling a function using as your name the content a CString Pin
Albert Holguin27-Sep-11 9:33
professionalAlbert Holguin27-Sep-11 9:33 
GeneralRe: Calling a function using as your name the content a CString Pin
Samuel Nunes de Arruda27-Sep-11 10:09
Samuel Nunes de Arruda27-Sep-11 10:09 
GeneralRe: Calling a function using as your name the content a CString Pin
Samuel Nunes de Arruda27-Sep-11 10:09
Samuel Nunes de Arruda27-Sep-11 10:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.