views:

200

answers:

2

Hi

Can we define interfaces in c++ using visulastudio?

if yes plz help me in defining interfaces in c++ with example...

Thanks in advance

+1  A: 

C++ does not have a concept of "interface" per se. They are usually emulated with abstract classes with pure virtual functions. Moreover, classes are usually substituted with structs, since default access modifier for those is public. Hence,

struct IFoo
{
    virtual void Bar() = 0;
}

Also, see this.

Anton Gogolev
What about the memory leak you are causing at the destruction of the object! Base classes MUST have a public virtual destructor or a protected non-virtual destructor.
TimW
A: 

using namespace System;

interface class IFoo { String^ GetName(); };

David Yaw