初学者有关问题 进来随便回答下拿5分啊

菜鸟问题 进来随便回答下拿5分啊!!!! #include iostream#include cstdlibclassdistance{intlengthpub

菜鸟问题 进来随便回答下拿5分啊!!!!

#include <iostream>
#include <cstdlib>
class   distance
{
    int   length;
    public:
        distance()
        {
        }
        distance(int   temp)
        {
            length=temp;
        }
       
        void   operator   =(distance   s)
        {
            s.length=length;
            cout < < "new   length= " < <s.length < <endl;
        }    
};

void   main()
{
    distance   obj1(200);
    distance   obj2;
    obj2=obj1;
    system( "pause ");
}


根据题目意思 输出的应该是new   length=200   但是在main函数里面随便怎么改变ojb1的参数 结果都是输出new   length=2293644   请教哪里写错了-_-!新手一个 请指教 改对了,5分都给您

[解决办法]
distance() : length(0)
{
}

void operator =(const distance & s)
{
length=s.length;
cout < < "new length= " < <length < <endl;
}
兄弟,看书要认真啊。