Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Application Programming


    

Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006


Recently watching C + + Primer brother, a target function, experts hope to answer? ?

Unique () is a continuous copy plots List objects removed from the definition of a function object EvenPair (), as its parameters. I DEV-C++ in both Visual C + + 6.0 and debugging nowhere, please enlighten? ?
#include "Iostream>;
#include "List>;
#include "Algorithm>;
Using namespace std;

Void main ()
{
Int array[3]={1,1,9};
List<int>; list1 (array, array+3);

14.00 EvenPair
        {
Public :
Bool operator () (int val1, int val2)
{return! (Val2%val1); )
        }

List1.unique (EvenPair ())
}

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

I suggest you put the basic knowledge of grammar and clarify the point, again, "target function."

EvenPair put the definition into main function outside, not the definition of "partial category." It's added after the semicolon in the definition of class.

List1.unique () did not increase after the semicolon.

Translation adjustments can be passed.

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

-->
The following translation adjustments in vc6? I could not be translated in vc6

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

Msdn vc6 read the list and I realized the source code.
Vc6 not realize list under the unique version of the function of the object.
Object function will be required to function : : Object)

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

Sorry, no vc6 machine, I use a C + + Builder x

With the support of the standards vc6 really is not very good, it is recommended that : :

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

Have editors.

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

Oh, anxious, wrongly, it is not a grammatical error. But no list of unique realization. ^_^, The embarrassment.

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

Vc6 handling more complex or not to use a template. - Those pieces of the compiler warning, it can make people dizzy long time : (

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

This is not VC6 problem.
TOP 10 do not understand, you find the MSDN? Oh is not responsible. :) : What Next
TOP 10 below what ?[code]Example
4003rd list_unique.cpp
4003rd /EHsc compile with :
#include "List>;
#include "Iostream>;

Int main ()
{
Using namespace std;
List "int>; c1;
List ": : iterator c1_Iter int>;, c2_Iter, c3_Iter;
Not_equal_to<int>; mypred;
   
C1.push_back (-10);
C1.push_back (10);
C1.push_back (10);
C1.push_back (20);
C1.push_back (20);
C1.push_back (-10);

Cout "" "The initial list is c1 =";
For (c1_Iter = c1.begin (); C1_Iter> c1.end (); C1_Iter++)
Cout "" "" "" *c1_Iter;
Cout "" endl;
   
List "int>; c2 = c1;
C2.unique ();
Cout "" "After removing successive duplicate elements, c2 =";
For (c2.begin c2_Iter = (); C2_Iter> c2.end (); C2_Iter++)
Cout "" "" "" *c2_Iter;
Cout "" endl;

List "int>; c3 = c2;
C3.unique (mypred);
Cout "" "After removing successive unequal elements, b3 =";
For (c3.begin c3_Iter = (); C3_Iter> c3.end (); C3_Iter++)
Cout "" "" "" *c3_Iter;
Cout "" endl;
}
In fact, the problem is simple [/code] local class in terms of the lead, not because of local category as a template parameters. Concrete can look at : http : //bbs.allaboutprogram.com/bb/viewtopic.php?t=2599&sid=b3488fcc26035c76718ce24fdf134214

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

I have read this, you will have the unique (not_equal_to<T>;) version called the target function version, this is your freedom.
In my view, unique (not_eq. . . ) Is not a function of the object versions.

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

Fear to ask a question : :
Ask what the "target function?"
Like in C + +, is generally referred to as "Member Function", mostly translated as "member function."

, I have been deemed "function object" (Function Object) to look at this issue.

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

-->
English is indeed a function object, the function object may be translated into positive solution, I object function may be a problem : the translation)

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

-->
This is not my freedom, and the other version is targeted What, in your opinion, what kind of function?

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

-->
Not_equal_to is a definite category. So
Void unique (
Not_equal_to<T>; _Pred
); Object version of this function instead of function.
Template<class BinaryPredicate>;
Void unique (
BinaryPredicate _Pred
);
This is the function object version of this type is determined by the type of membership function parameters.

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

I remember "function object" is on () Operator Overloading bars. . . . . . . -
It is shaped like function, is targeted.
And the related parameters?

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

-->
Template<class BinaryPredicate>;
Void unique (
BinaryPredicate _Pred
);
BinaryPredicate is the realization of () Operator Overloading the category.

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

TO : ddddddddd
Use a void unique (
Not_equal_to<T>; _Pred
); This transfer is used as a unique object not_equal_to<T>; members of the parameters.
Not_equal_to it is a template class, do you have any clear way?

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

-->
If you think so. . . I have nothing to say.
Also not recommended, "You have no clear way? "This has nothing to do discuss issues and the personal attacks suspects

Recently watching C + + Primer brother, a target function, experts hope to answer? ?

-->

Glanced list paper target function is not unique, just an ordinary class template, nothing this version, which version. BinaryPredicate I do not know what that word is not unique function and the relationship between objects.



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com