Not defined member function in class template

Ask a question
1

I have this code

template<class T>
struct Z
{
   void f() {}
   void g(); // never defined
};

int main()
{
   Z<int> a;
   Z<char>* p;
   p->f();

   return 0;
}

It compiles and runs.

What I don’t understand is how it works if member function g() is not defined. Only when I call g() it gives linage error.

Coin iconoffer bounty
add comment

0 Answer

Your Answer