Jump to content
  • Advertisement
Sign in to follow this  
guyaton

programming interfaces

This topic is 5135 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am trying to create an interface
[uuid(336389EB-B3BA-4278-9107-28EA51F552DA)]
interface IParserFile : IUnknown
{
	HRESULT LoadFile( [in, string]char *strFileName );
};



but it keeps having compiling errors. does anyone know a good website that explains them really well? Do they work like C++ classes with public, private, protected ? thanks!

Share this post


Link to post
Share on other sites
Advertisement
What you posted is not C++... C++ has no support for interfaces. If you want to do an interface, just create a class and make all functions pure virtual...

Oxyd

Share this post


Link to post
Share on other sites
Quote:
Original post by guyaton
i am trying to create an interface
*** Source Snippet Removed ***

but it keeps having compiling errors. does anyone know a good website that explains them really well? Do they work like C++ classes with public, private, protected ?

thanks!

Also, telling us that you have errors is not helpful in the slightest, atleast give us the errors you are getting.

Share this post


Link to post
Share on other sites
Ok, this is what I have so far:


[uuid(336389EB-B3BA-4278-9107-28EA51F552DA)]
interface IParserFile : IUnknown
{
IParserFile();
HRESULT LoadFile( [in, string]char *strFileName );
};

typedef IParserFile *LPPARSERFILE;



and here's the errors:

error C3303: 'in': attribute can only be used on 'interface methods, interface method parameters, method parameters, idl_module methods'

eerror C3303: 'string': attribute can only be used on 'members, interface methods, interface method parameters, method parameters, idl_module methods, typedefs'

thanks for all the help


Share this post


Link to post
Share on other sites
i know this is a big streach and i appriciate the help 'n support....once you create one, how do you create an instance of it, because as we all know these are not allowable:


LPPARSERFILE test = NULL;
test = new IParserFile();

IParserFile test;




Microsoft has functions that "create" them for example

LPDIRECTXFILE lpDXFile;
hr = DirectXFileCreate( &lpDXFile )



how would i create one of those?

thanks!

Share this post


Link to post
Share on other sites
Quote:
Original post by guyaton
i know this is a big streach and i appriciate the help 'n support....once you create one, how do you create an instance of it, because as we all know these are not allowable:

*** Source Snippet Removed ***

Microsoft has functions that "create" them for example
*** Source Snippet Removed ***

how would i create one of those?

thanks!
There's nothing magical about the construction of COM objects.
Just add a constructor as usual or make it private and wrap it up in an external function like microsoft does.
The reason that you might want do make it external is that the interface is generally fully virtual and any constructor is placed in the actual (and internal) class implementation.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!