English 中文(简体)
卸载指派操作员 C++
原标题:Overloading the assignment operator C++

家务劳动转让要求货物经营人超负荷工作,以支付一个海普班,该班用于储存点站,在每一节点安装点,以图形成一个紧急房间优先点。

下面是我提出的法典:

    template <typename T>
    Heap<T>& Heap<T>::operator=(const Heap<T> & rhs)
    {
        //check for self-assignment
        if(this != &rhs)
        {
            //delete memory
            for(int i = 0; i < MAX_HEAP; i++)
            {
                //delete queue at position i, set pointer to NULL
                delete items[i];
                items[i] = NULL;
            }//end for
            delete * items;

            //create new memory to hold copy of rhs

                        //error occurs here
            items = new queue<T> *[MAX_HEAP] ;

            for(int i = 0; i < MAX_HEAP; i++)
                items[i] = rhs.items[i];

            //assigns new stuff to this heap
            size = rhs.size;
            nodes = rhs.nodes;

        }//end if
        return *this;
    }//end =

标书上注明的是:

    queue<T>* items[MAX_HEAP];

并且是标准图书馆地点的例子。

我不相信,我是否利用适当的辛迪加来建立一个新的动态的轮.点。

I am getting an error that says:

    error C2440:  =  : cannot convert from  std::queue<_Ty> **  to  std::queue<_Ty> *[50] 

关于什么原因以及我如何解决这一问题的想法?

问题回答

页: 1

此外,<代码>delete*项目;应改为delete[] 项目;

EDIT - I forgot to Add<T> after std:queue

<代码>new 返回原样的点子,因此现在不匹配。 我可以告诉大家,你对新物品或新物品的申报是你所说的,但新物品的间接程度比项目多。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签