Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3332256
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:40:07+00:00 2026-05-17T23:40:07+00:00

I have following template code: class ClassName{}; template <class T> class TemplatePtr { public:

  • 0

I have following template code:

class ClassName{};

template <class T>
class TemplatePtr
{
public:
    void operator=(T* p)
    {

    }
};

class TemplatePtr_ClassName: public TemplateePtr<ClassName>
{
public:
    ~TempaltePtr_ClassName();
};


void Test()
{
    TemplatePtr_ClassName data;
    data = new ClassName;
}

but compile fails with error message (VS2008):

error C2679: binary ‘=’ : no operator found which takes a right-hand operand of type >>’ClassName *’ (or there is no acceptable conversion)

Why it won’t work as I have defined an operator in the template base class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:40:07+00:00Added an answer on May 17, 2026 at 11:40 pm

    operator = is always hidden by the derived class implementation unless explicit using declaration is provided. This is true for both class templates and ordinary classes.

    BTW, your declaration of operator= is very nonstandard. It is usually declared so for a class ‘A’.

    A& operator=(A const &);
    

    Here is something that may be what you are looking for (and compiles)

    template <class T> 
    class TemplatePtr 
    { 
    public: 
        TemplatePtr& operator=(TemplatePtr const &) 
        {return *this;} 
    }; 
    
    template<class T>
    class TemplatePtr_ClassName: public TemplatePtr<T> 
    { 
    public:
       ~TemplatePtr_ClassName(){};
       TemplatePtr_ClassName& operator=(TemplatePtr_ClassName const &that){
          TemplatePtr<T>::operator=(that);        // invoke base class assignment operator
          return *this;
       }
    }; 
    
    
    int main() 
    { 
        TemplatePtr_ClassName<int> data; 
        data = *new TemplatePtr_ClassName<int>; 
        // delete stuff
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: template <class T> struct pointer { operator pointer<const T>()
I have the following code: template <typename Provider> inline void use() { typedef Provider::Data<int>
I have the following code: class TimeOutException {}; template <typename T> class MultiThreadedBuffer {
I have the following piece of code which replaces template markers such as %POST_TITLE%
I have the following problem using template instantiation [*]. file foo.h class Foo {
To have an indexer we use the following format: class ClassName { DataType[] ArrayName
In MSVC 2008, I have the following code: class Foo { // Be a
I have the following template <h2>one</h2> <xsl:apply-templates select=one/> <h2>two</h2> <xsl:apply-templates select=two/> <h2>three</h2> <xsl:apply-templates select=three/>
I have the following xsl template that I'm using to group my xsl. The
I have the following simple button with an image as the template. The problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.