Home selfpointer inside template friend function
Reply: 0

selfpointer inside template friend function

user851
1#
user851 Published in May 21, 2018, 9:18 am

How can I get pointer to object in friend function?

def.h

class A
{
public:
     template <typename some_type_t>
     friend void foo(some_type_t &val);

     A();
     virtual ~A();    
private:
     int x;
     inline A* GetSelfPtr(){return this;}
};

class B
{
public:
      template <typename some_type_t>
      friend void foo(some_type_t &val);

      B();
      virtual ~B();    
private:
      int x;
      inline B* GetSelfPtr(){return this;} 
};
#include "templt.h"

templt.h

template <typename some_type_t>
void foo(some_type_t &val)
{
     GetSelfPtr()->x;
}

error: there are no arguments to ‘GetReqPtr’ that depend on a template parameter, so a declaration of ‘GetReqPtr’ must be available [-fpermissive]

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.369876 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO