Skip to main content
gamedev.net
🔒 Locked

interface keyword

Started by Muncher Dec 30, 2003 at 7:26 AM 2 replies 500+ views
Original Post
Muncher
Muncher
can someone give me an example of where to use this??? cheers
SiCrane
SiCrane
It might help if you specified a programming language.
McGyverDK
McGyverDK
A interface is like a set of rules for an object. All objects that can go into my 3D Engine Object Manager must implement my BasicObject interface.

In the interface I define only a simple thing, that all objects must have a render function. Without that, they are not allowed in my manager class. So all objects is based on this interface.

This is C# code:

public interface IBasicObject
{
void Render();
}

If the objects don''t have a render function and implements the interface, the compilation will fail.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.