Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Annoying C++ Inheritance error

This topic is 5989 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''m writing a driver that will read data from a non-HID controller and emulate a HID device. When I compile my code using DriverWorks, I receive the following message. NTSTATUS XHidMiniDriver::AddDevice(PDEVICE_OBJECT Fdo) { NTSTATUS status; // This is the Erring line XHidDevice* p = new (NonPagedPool) XHidDevice(Fdo); if (p == NULL) status = STATUS_INSUFFICIENT_RESOURCES; else { status = p->ConstructorStatus(); if ( !NT_SUCCESS(status) ) delete p; } return status; } class XHidDevice : public KHidDevice { SAFE_DESTRUCTORS public: // Constructor; Part of problem XHidDevice(PDEVICE_OBJECT Fdo); NTSTATUS ReadReport(KIrp I); NTSTATUS DefaultHidRequestHandler(KIrp I); NTSTATUS DefaultPower(KIrp I); NTSTATUS DefaultPnp(KIrp I); }; For those who don''t know about DriverWorks, KHidDevice has no constructor with zero parameters. However, it does have a constructor that takes a PDEVICE_OBJECT. How do I get XHidDevice to call KHidDevice''s constructor? When I compile, I receive this message XHID\XHIDDevice.cpp(14) : error C2512: ''KHidDevice'' : no appropriate default constructor available

Share this post

Link to post
Share on other sites
in the implementation of the constructor (.cpp file probs)

XHidDevice::XHidDevice(PDEVICE_OBJECT Fdo): KHidDevice(Fdo) {

//whatever stuff you have in the constructor



Share this post

Link to post
Share on other sites
Alright, I tried the suggestion, and now I get the following error:

XHID\XHIDDevice.cpp(14) : error C2664: ''__thiscall KHidDevice::KHidDevice(class KHidDevice &)'' : cannot convert parameter 1 from ''struct _DEVICE_OBJECT *'' to ''class KHidDevice &''
A reference that is not to ''const'' cannot be bound to a non-lvalue

I have no idea where it''s getting that constructor, seeing as how the constructor definition is

ULONG ReportLength,
PWCHAR HardwareIDs,
PWCHAR CompatibleIDs,
PWCHAR InstanceID,
ULONG DeviceStringSize,
UCHAR CountryCode=0

Share this post

Link to post
Share on other sites
wait, if the base class constructor expects ALL those parameters you have to pass ALL of those parameters in the : KHidDevice(....) call. you can't just pass one parameter if there is no existing KHidDevice constructor that only excepts one parameter.

i also don't know where it's getting that constructor but you are definitely confusing the compiler if you are trying to call a constructor with only one parameter that expects 11....


[edited by - Palidine on May 30, 2002 6:12:48 PM]

Share this post

Link to post
Share on other sites

  • 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!