programming interfaces

Started by
15 comments, last by doynax 19 years, 6 months ago
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!
~guyaton
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
but that's no fun, how do I create an Interface? I'm curious now.

~guyaton
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.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

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


~guyaton
A short description of the macro magic involved.
Only explains some of the technical details of declaring a COM interface manually though.

I'm guessing that sample code uses attributed C++, something I doubt you'll get much help with on gamedev.
thats a good start...thanks!


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

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!

~guyaton
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.
I'm still not fully sure, would you mind a real simple demo?

thanks.

~guyaton

This topic is closed to new replies.

Advertisement