Generic Interface syntax in VS 2005 using Old syntax

  • Thread starter Thread starter Saad
  • Start date Start date
S

Saad

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
 
Hi Saad!
generic<typename T>
public __gc__interface IFace
{
public:
void FuncA(T obj);
}

But im getting the following error:-

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

If you compiled with "/clr:oldSyntax", then there is no way to use
features of the *new* syntax (which makes sense).

You can try to compile this particular file with "/clr" and all other
files with "/clr:oldSyntax".
Of course, you have to disable precompiled headers for this to work...


Greetings
Jochen
 
Saad said:
Hi All,

Im using managed c++ syntax (VS 7) in VS 2005. And i want to implement
a generic interface in it.

VS2002/2003 didn't support generics in C#, VB, or C++. You need to upgrade
to the C++/CLI syntax introduced in VS2005 to get any of the new features.
 
Back
Top