none
Warning 2 warning C4995: 'ConstructElements': name was marked as #pragma deprecated

    Question

  • Warning 2 warning C4995: 'ConstructElements': name was marked as #pragma deprecated d:classarr.h 53 

     

    the code is as follow:

    public:

    template<class TYPE, class ARG_TYPE>
    class CClassArray
    {

    ...................

    ...................
     void ConstructElements(TYPE* pElements, int nCount);

    ...................

    }

    void CClassArray<TYPE, ARG_TYPE>::ConstructElements(TYPE* pElements, int nCount)
    {
     // first do bit-wise zero initialization
     memset((void*)pElements, 0, nCount * sizeof(TYPE));
     // then call the constructor(s)
     for (; nCount--; pElements++)
      ::new((void*)pElements) TYPE;
    }

    I only give a few code. Because ConstructElements  function was declared deprecated, but  I do not use the orignal defintion of this function  and I redefintion this function. If I ingnore this warning, is  it  a problem for the program to run.

     

    I appreciate your help.


     

    Tuesday, August 29, 2006 8:40 AM

Answers

  • If that method was declared as deprecated, I am sure there's a replacement method or methods that can be used to achieve the same functionality. Perhaps you should look at that option.
    Tuesday, August 29, 2006 2:23 PM
  • It looks like you've been copying and pasting code out of the MFC afxtempl.h header file.  I see ConstructElements indeed marked as deprecated with the remark: 'Use a constructor/destructor instead'.  This is indeed very good advice, ConstructElements just zero-initializes the class objects.  Which is appropriate only if the class members are simple native C++ types.  ConstructElements used to be used by the MFC CMap class but the calls are commented out in the VS2005 version of the CMap::NewAssoc() method...
    Tuesday, August 29, 2006 2:32 PM

All replies

  •  su wrote:

    but  I do not use the orignal defintion of this function  and I redefintion this function.

    What do you mean?

     su wrote:
    If I ingnore this warning, is  it  a problem for the program to run.

    Is that a question or a statement?

    Tuesday, August 29, 2006 11:57 AM
  • I mean : Can I ignore this warning? i thank you here in advance.
    Tuesday, August 29, 2006 2:05 PM
  • If that method was declared as deprecated, I am sure there's a replacement method or methods that can be used to achieve the same functionality. Perhaps you should look at that option.
    Tuesday, August 29, 2006 2:23 PM
  • It looks like you've been copying and pasting code out of the MFC afxtempl.h header file.  I see ConstructElements indeed marked as deprecated with the remark: 'Use a constructor/destructor instead'.  This is indeed very good advice, ConstructElements just zero-initializes the class objects.  Which is appropriate only if the class members are simple native C++ types.  ConstructElements used to be used by the MFC CMap class but the calls are commented out in the VS2005 version of the CMap::NewAssoc() method...
    Tuesday, August 29, 2006 2:32 PM
  •  su wrote:

    I do not use the orignal defintion of this function  and I redefintion this function.

    Do you mean that you have overloaded the ConstructElements function?

    Tuesday, August 29, 2006 3:05 PM
  • Yes , I overload the function of ConstructElements, so will it a problem ? Can i ignore the warning at the stage? I thank you here in advance.
    Wednesday, August 30, 2006 12:42 AM