Windows Vista Forums

Generic Interface syntax in VS 2005 using Old syntax
  1. #1


    Saad Guest

    Generic Interface syntax in VS 2005 using Old syntax

    Hi All,

    Im using managed c++ syntax (VS 7) in VS 2005. And i want to implement
    a generic interface in it.
    But im getting errors when i try to compile the code.

    Here is what i want to do:-
    Like if you have following in C#:-

    public interface IFace<T>
    {
    void FuncA(T obj);
    }

    Then how to write it in managed c++.
    I tried with this:-

    generic<typename T>
    public __gc__interface IFace
    {
    public:
    void FuncA(T obj);
    }



    But im getting the following error:-

    error c2143: syntax error : missing ';' before '<'

    So, please let me know what is the issue here?

    Im assuming that we can implement generic interface in managed C++,
    since i have also used generic collections in the project as
    well....or my assumption is wrong?

    Thanks,
    Saad

      My System SpecsSystem Spec

  2. #2


    David Anton Guest

    RE: Generic Interface syntax in VS 2005 using Old syntax

    3 things:
    1. I think for the 'old' syntax, you might need to use 'template', not
    'generic'.
    2. You need a space between "__gc" and "__interface".
    3. You need a semi-colon to close the type.
    --
    David Anton
    http://www.tangiblesoftwaresolutions.com
    Convert VB to C#, C++, or Java
    Convert C# to VB, C++, or Java
    Convert C++ to C#, VB, or Java
    Convert Java to C#, C++, or VB


    "Saad" wrote:

    > Hi All,
    >
    > Im using managed c++ syntax (VS 7) in VS 2005. And i want to implement
    > a generic interface in it.
    > But im getting errors when i try to compile the code.
    >
    > Here is what i want to do:-
    > Like if you have following in C#:-
    >
    > public interface IFace<T>
    > {
    > void FuncA(T obj);
    > }
    >
    > Then how to write it in managed c++.
    > I tried with this:-
    >
    > generic<typename T>
    > public __gc__interface IFace
    > {
    > public:
    > void FuncA(T obj);
    > }
    >
    > But im getting the following error:-
    >
    > error c2143: syntax error : missing ';' before '<'
    >
    > So, please let me know what is the issue here?
    >
    > Im assuming that we can implement generic interface in managed C++,
    > since i have also used generic collections in the project as
    > well....or my assumption is wrong?
    >
    > Thanks,
    > Saad
    >

      My System SpecsSystem Spec

Generic Interface syntax in VS 2005 using Old syntax problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with syntax hansel PowerShell 7 14 Dec 2008
"invalid STORE command syntax invalid message set syntax" Catullus Nacakus Vista mail 6 26 Jan 2008
Help with Powershell syntax DaveKingston PowerShell 26 25 Oct 2007
need syntax carmine934 Vista hardware & devices 0 02 Jun 2007
Syntax question Jim Holbach PowerShell 2 08 Jun 2006