Hello, I need to update my older Autodesk plug-in. And I am having troubles get it through. (They changed one function)

This is a new definition which I cannot change:

CoreExport virtual void EnumAuxFiles(AssetEnumCallback& assetEnum, DWORD flags);

And here is my code:

class CheckFileNames: public AssetEnumCallback {
public:
	NameTab* missingMaps;
	BitmapInfo bi;
	CheckFileNames(NameTab* n);
	void RecordName(TCHAR *name);
};

CheckFileNames::CheckFileNames(NameTab* n)
{
	missingMaps = n;
}

int LoadMapFiles(INode* node, SContext* sc, MtlBaseLib& mtls, TimeValue t)
{
	NameTab mapFiles;	
	CheckFileNames checkNames(&mapFiles);  // HERE is the bug
     //error C2259: 'CheckFileNames' : cannot instantiate abstract class

	node->EnumAuxFiles(checkNames, FILE_ENUM_MISSING_ONLY |FILE_ENUM_1STSUB_MISSING);
}

My C++ is quite rusty by now, but if I understand it correctly: the new definition is a pure virtual function which makes my class abstract.
How do I correct it ?
(Perhaps I should inherit from my class somehow, but what is the proceeding ?)
Thank you very much for any kind of help.

What you have there is not a pure virtual function, but just virtual function.
A purely virtual function would be like: CoreExport virtual void EnumAuxFiles(AssetEnumCallback& assetEnum, DWORD flags)=0; .
A simple virtual function means only one thing: it can be re-defined by it's child classes.

There is a good description of this at cplusplus.com, if my explanation wasn't enough.

Thank you. Yes you are absolutely right, but why Am I getting - cannot instantiate abstract class error ?

Hard to say, but my guess is you don't implement a pure virtual function that is in the class from which you inherit. Could you give a link to docs?

Also, for more extensive error descriptions, just google "Visual Studio error" adding the error you get. Microsoft provides nice descriptions, which sometimes are pretty helpful. Not this time though.

Good idea. So here is the error descrition.

'CheckFileNames' : cannot instantiate abstract class
due to following members:
'void AssetEnumCallback::RecordAsset(const MaxSDK::AssetManagement::AssetUser &)' : pure virtual function was not defined
c:\Program Files\Autodesk\3ds Max 2012\maxsdk\include\AssetEnumCallback.h(41) : see declaration of 'AssetEnumCallback::RecordAsset'

Adn here is the code:

namespace MaxSDK
{
	namespace AssetManagement
	{
		class AssetUser;
	}
}

// A callback object passed to EnumAuxFiles().

class AssetEnumCallback : public MaxHeapOperators
{
public:
	/*! \remarks Destructor. */
	virtual ~AssetEnumCallback() {}
	/*! \remarks This method is used to record the asset passed.
	\par Parameters:
	<b>const MaxSDK::AssetManagement::AssetUser& asset</b>\n\n
	The asset to store. */
	virtual void RecordAsset(const MaxSDK::AssetManagement::AssetUser& asset)=0;
};

I am pretty hopeless...
Here is th only def. I found.

Animatable::EnumAuxFiles() - a developer derives a class from this class and implements the RecordAsset() method to store each asset as it's passed to it.

How do I add it just to compile correctly?

Just make an empty method or something, should work IMO.

The question here is, how will that work with Max.
Since the arg is a const reference it shouldn't have much of an impact though.

"Just make an empty method" I would need a little help. How to do it ?
(I know it sounds stupid but I haven't touched c++ in 10 years...)

No problem ;P

Inside your class:

void RecordAsset(const MaxSDK::AssetManagement::AssetUser& asset){
int a;
}

Sorry for the lack of indentation, wrote it in the forum posting box.

"Just make an empty method" I would need a little help. How to do it ?
(I know it sounds stupid but I haven't touched c++ in 10 years...)

You would just make a function put nothing in the brackets except for a return; statement in this case. If the function was non-void you'd probably want it to return an actual value. The following should probably work:

void CheckFileNames::RecordAsset(const MaxSDK::AssetManagement::AssetUser& asset)
{
    return;
}

Och, so simple. (definitively not my day today :) )
Thank you very much for the help.

Now I must run series of tests if Autodesk's new RecordAsset has any impact...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.