Generic Interface syntax in VS 2005 using Old syntax

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
 
J

Jochen Kalmbach [MVP]

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:blush:ldSyntax", 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:blush:ldSyntax".
Of course, you have to disable precompiled headers for this to work...


Greetings
Jochen
 
B

Ben Voigt [C++ MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top