Home > Back-end >  Class template forward declarations and ordinary class why don't you
Class template forward declarations and ordinary class why don't you

Time:11-22

When you learn c + + read such code
 
Template
The class SharedPointer;

Template
Auto swap (SharedPointer & LHS, SharedPointer & RHS)
{
Using STD: : swap;
Swap (LHS) PTR, RHS. PTR);
Swap (LHS) ref_count, RHS. Ref_count);
Swap (LHS. Deleter, RHS. Deleter);
}

If SharedPointer is normal class, then the forward declarations defined before, certainly not the use of its members, can only use it a pointer or reference, but why class template after forward declaration, definition, members will be able to use it?
  • Related