CList<type1,type2>
这里的type1要支持=操作符
看看Afxtempl.h里的源代码就知道了

解决方案 »

  1.   

    给你的CNode1类重载oprator =
      

  2.   

    ancienttale:
       请说清楚一点,我编译是好象出现过那样的提示,。但我不清楚是什么意思。
    ”重载oprator =“是什么回事?
      

  3.   

    I服了U了,操作符重载
    General Rules for Operator Overloading
    The following rules constrain how overloaded operators are implemented. However, they do not apply to the new and delete operators, which are covered separately in Chapter 4. Operators must either be class member functions or take an argument that is of class or enumerated type or arguments that are references to class or enumerated types. For example:
    class Point
    {
    public:
        Point operator<( Point & );  // Declare a member operator 
                                     //  overload.
        ...
        // Declare addition operators.
        friend Point operator+( Point&, int );
        friend Point operator+( int, Point& );
    };The preceding code sample declares the less-than operator as a member function; however, the addition operators are declared as global functions that have friend access. Note that more than one implementation can be provided for a given operator. In the case of the preceding addition operator, the two implementations are provided to facilitate commutativity. It is just as likely that operators that add a Point to a Point, int to a Point, and so on, might be implemented.Operators obey the precedence, grouping, and number of operands dictated by their typical use with built-in types. Therefore, there is no way to express the concept “add 2 and 3 to an object of type Point,” expecting 2 to be added to the x coordinate and 3 to be added to the y coordinate.
    Unary operators declared as member functions take no arguments; if declared as global functions, they take one argument.
    Binary operators declared as member functions take one argument; if declared as global functions, they take two arguments.
    Overloaded operators cannot have default arguments.
    All overloaded operators except assignment (operator=) are inherited by derived classes.
    The first argument for member-function overloaded operators is always of the class type of the object for which the operator is invoked (the class in which the operator is declared, or a class derived from that class). No conversions are supplied for the first argument. 
    Note that the meaning of any of the operators can be changed completely. That includes the meaning of the address-of (&), assignment (=), and function-call operators. Also, identities that can be relied upon for built-in types can be changed using operator overloading. For example, the following four statements are usually equivalent when completely evaluated:var = var + 1;
    var += 1;
    var++;
    ++var;This identity cannot be relied upon for class types that overload operators. Moreover, some of the requirements implicit in the use of these operators for basic types are relaxed for overloaded operators. For example, the addition/assignment operator, +=, requires the left operand to be an l-value when applied to basic types; there is no such requirement when the operator is overloaded.Note   For consistency, it is often best to follow the model of the built-in types when defining overloaded operators. If the semantics of an overloaded operator differ significantly from its meaning in other contexts, it can be more confusing than useful.