#include<iostream.h>
class AA
{
public:
AA(int i,int j)
{
A=i;B=j;
cout<<"Constructor.\n";
}
~AA(){cout<<"Destructor.\n";}
void print();
private:
int A,B;
};
void AA::print()
{
cout<<A<<","<<B<<endl;
}
void main()
{
AA a1,a2;
a1=new AA(1,2);
a2=new AA(5,6);
a1->print();
a2->print();
delete a1;
delete a2;
}
错误提示是:
--------------------Configuration: 1111 - Win32 Debug--------------------
Compiling...
1111.cpp
D:\软件\VC6\MyProjects\1111\1111.cpp(22) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class AA *' (or there is no acceptable conversion)
D:\软件\VC6\MyProjects\1111\1111.cpp(23) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class AA *' (or there is no acceptable conversion)
D:\软件\VC6\MyProjects\1111\1111.cpp(24) : error C2819: type 'AA' does not have an overloaded member 'operator ->'
D:\软件\VC6\MyProjects\1111\1111.cpp(3) : see declaration of 'AA'
D:\软件\VC6\MyProjects\1111\1111.cpp(24) : error C2227: left of '->print' must point to class/struct/union
D:\软件\VC6\MyProjects\1111\1111.cpp(25) : error C2819: type 'AA' does not have an overloaded member 'operator ->'
D:\软件\VC6\MyProjects\1111\1111.cpp(3) : see declaration of 'AA'
D:\软件\VC6\MyProjects\1111\1111.cpp(25) : error C2227: left of '->print' must point to class/struct/union
D:\软件\VC6\MyProjects\1111\1111.cpp(26) : error C2440: 'delete' : cannot convert from 'class AA' to ''
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
D:\软件\VC6\MyProjects\1111\1111.cpp(26) : fatal error C1903: unable to recover from previous error(s); stopping compilation
执行 cl.exe 时出错.
1111.exe - 1 error(s), 0 warning(s)
婷婷同学_
慕神8447489
相关分类