Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Generic Interface syntax in VS 2005 using Old syntax

Reply
 
Old 06-09-2009   #1 (permalink)
Saad


 
 

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
Old 06-09-2009   #2 (permalink)
David Anton


 
 

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:
Quote:

> 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
Reply

Thread Tools


Similar Threads
Thread Forum
Help with syntax PowerShell
"invalid STORE command syntax invalid message set syntax" Vista mail
need syntax Vista hardware & devices
AD DirectorySearcher Syntax PowerShell
Syntax question PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46