Thread: Template Friend Workaround for MSVC?

  1. #1
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856

    Template Friend Workaround for MSVC?

    I figured out, once upon a time, the syntax to make a template class a friend. When I did that I was using Borland, but I am in the middle of an MFC app and am just now discovering that (as usual) MSVC is not handling this template functionality. What I need to know is if there is a workaround because if not, I will have to do the only other alternative and make a few private members public or provide accessors to them (how mongoloid is that?).

    To recap, this is what I'm trying to do:
    Code:
    class Foo {
      template <typename L>
      friend class Bar;
    
      int some_member;// that Bar needs to access
    };
    This does not even compile in MSVC (the primary error is "<end parse>"). I took a shot in the dark and tried leaving out the template line, but that just leaves instantiated objects of type Bar non-friends.

    Any bright (or even gloriously dim) ideas?
    Last edited by LuckY; 04-01-2005 at 03:41 PM.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    AFAIK, there's no workaround. You can either make the members that need to be accessed public, or upgrade to a proper compiler. (VS.Net 2003)
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Replies: 8
    Last Post: 07-24-2006, 08:14 AM
  3. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  4. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 12:54 PM