请教c++高手, 关于自定义的类相互赋值的问题..........请看代码!
c++中同类对象是可以相互赋值,,为何下列语句,运行会出错....
原因何在...
请高手讲解!!!!!
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
///#include "datastruct.h"
class t
{
private :
char *p ;
public :
t(int n)
{
p = new char[n];
};
~t()
{
delete []p ;
};
};
void main()
{
t t1(3),t2(4) ;
t2 = t1 ; //---该语句引起报错......
return ;
};