CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Threaded View

  1. #1
    Join Date
    Jun 2018
    Posts
    3

    Code worked in VS6 but not in VS2017

    The following code worked before with VS6 VC++. But it does not complete the compiling with VS2017 VC++ (Link error is shown below). The complete template is in a .h file. What was changed in VS2017? What needs to be done to resolve the error? Please help. Thanks.

    error LNK2019: unresolved external symbol "class CArrayEx<double,double> __cdecl operator-(class CArrayEx<double,double> const &,class CArrayEx<double,double> const &)" (??G@YA?AV?$CArrayEx@NN@@ABV0@0@Z) referenced in function "public: int __thiscall CMathEx::QNSS(class CArrayEx<double,double> const &,class CArrayEx<double,double> &,class CArrayEx<double,double> &,double &,double &,int &,int)" (?QNSS@CMathEx@@QAEHABV?$CArrayEx@NN@@AAV2@1AAN2AAHH@Z)

    Code:
    //
    template<class TYPE, class ARG_TYPE> 
    class CArrayEx : public CArray<TYPE,ARG_TYPE>
    {
    public:
    	CArrayEx(){}
    	......
    	friend CArrayEx<TYPE,ARG_TYPE>	operator + (const CArrayEx<TYPE,ARG_TYPE>& za1,const CArrayEx<TYPE,ARG_TYPE>& za2);
    	......
    };
    
    template<class TYPE, class ARG_TYPE> 
    CArrayEx<TYPE,ARG_TYPE> operator + (const CArrayEx<TYPE,ARG_TYPE>& za1,const CArrayEx<TYPE,ARG_TYPE>& za2)
    {
    	CArrayEx<TYPE,ARG_TYPE> za;
    	za.SetSize(min(za1.GetSize(),za2.GetSize()));
    
    	for (int i=0;i<za.GetSize();i++)
    	{
    		za[i]=za1[i]+za2[i];
    	}
    	return za;
    }
    Last edited by 2kaud; June 26th, 2018 at 03:10 AM. Reason: Added code tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured