"Default Constructor" error?

"samusaran.cpp(16) : error C2512: 'hgeEntityEx' : no appr

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 1979 Views - Last Post: 23 January 2010 - 03:51 PM Rate Topic: -----

#1 Portalboat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 04-December 09

"Default Constructor" error?

Posted 19 January 2010 - 08:44 PM

class entSamusAran: public hgeEntityEx
{
private:
.......

	// Constructor
	hgeEntityEx(int m_Layer, bool m_Static) : hgeEntity(m_Layer, m_Static)
	{
		rot = 0;
		scale = 1;
	}



So yeah. I have no idea what's going on.... (again :P)

Is This A Good Question/Topic? 0
  • +

Replies To: "Default Constructor" error?

#2 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3106
  • View blog
  • Posts: 19,145
  • Joined: 14-September 07

Re: "Default Constructor" error?

Posted 19 January 2010 - 08:47 PM

How the hell are we supposed to know what's wrong?

There's no clear error message and no code to determine context.

Running through a few of the possible culprits:

1. No default constructor
2. You provide a parameter constructor, but try to use one without any parameters
3. You have some inheritance issues
Was This Post Helpful? 0
  • +
  • -

#3 Portalboat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 04-December 09

Re: "Default Constructor" error?

Posted 19 January 2010 - 09:12 PM

....I thought I posted all of the needed code.
What do you need?
Was This Post Helpful? 0
  • +
  • -

#4 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3106
  • View blog
  • Posts: 19,145
  • Joined: 14-September 07

Re: "Default Constructor" error?

Posted 19 January 2010 - 09:37 PM

This got cut off

error C2512: 'hgeEntityEx' : no appr


And there's not enough code. Like I said best guess with what we have is that hgeEntityEx doesn't have a default constructor.
Was This Post Helpful? 0
  • +
  • -

#5 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5363
  • View blog
  • Posts: 27,325
  • Joined: 10-May 07

Re: "Default Constructor" error?

Posted 19 January 2010 - 09:40 PM

There's no appr like good appr.
Was This Post Helpful? 0
  • +
  • -

#6 Portalboat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 04-December 09

Re: "Default Constructor" error?

Posted 19 January 2010 - 10:03 PM

View Postno2pencil, on 19 Jan, 2010 - 08:40 PM, said:

There's no appr like good appr.


Indeed :P

samusaran.cpp(16) : error C2512: 'hgeEntityEx' : no appropriate default constructor available
^There's the FULL error. Which is what you thought.

Here's the only constructor in the header. I don't see why I need a default one.
	hgeEntityEx(int m_Layer, bool m_Static) : hgeEntity(m_Layer, m_Static)
	{
		rot = 0;
		scale = 1;
	}

Was This Post Helpful? 0
  • +
  • -

#7 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3106
  • View blog
  • Posts: 19,145
  • Joined: 14-September 07

Re: "Default Constructor" error?

Posted 19 January 2010 - 10:05 PM

How are you calling it in your program? With parameters right?


If at all possible, if you don't want to post the actual code, create a fake version that does the exact same thing. [different names, simpler, whatever, just something to look at]
Was This Post Helpful? 0
  • +
  • -

#8 Portalboat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 04-December 09

Re: "Default Constructor" error?

Posted 20 January 2010 - 07:52 AM

I'm pretty sure I'm calling the parameters right.

public:
	entSamusAran(HGE *_hge, InputHandler *_input);
	entSamusAran() : hgeEntityEx(HEL_MIDDLE2, false) {}  

Was This Post Helpful? 0
  • +
  • -

#9 Bench  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 857
  • View blog
  • Posts: 2,340
  • Joined: 20-August 07

Re: "Default Constructor" error?

Posted 20 January 2010 - 08:33 AM

Where's the definition for entSamusAran(HGE *_hge, InputHandler *_input);? You need to explicitly call the base class constructor for that one too. i.e.
entSamusAran(HGE *_hge, InputHandler *_input)
    : hgeEntityEx( /* args */ )
{
    //body
} 

This post has been edited by Bench: 20 January 2010 - 08:35 AM

Was This Post Helpful? 0
  • +
  • -

#10 Portalboat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 04-December 09

Re: "Default Constructor" error?

Posted 20 January 2010 - 03:50 PM

entSamusAran::entSamusAran(HGE *_hge, InputHandler *_input)
    : hgeEntityEx(HEL_MIDDLE2, false)
{
   input = _input;
   hge = _hge;
}


I had it without the : hgeEntityEx(HEL_MIDDLE2, false) before.

Now, I'm getting a bunch of linker errors:
msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in opal.lib(hgePolygonMap.obj)
msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in opal.lib(hgePolygonMap.obj)
msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in opal.lib(hgePolygonMap.obj)
msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in opal.lib(hgePolygonMap.obj)
msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::locale::facet * __thiscall std::locale::facet::_Decref(void)" (?_Decref@facet@locale@std@@QAEPAV123@XZ) already defined in opal.lib(hgeProperties.obj)
LINK : fatal error LNK1104: cannot open file 'LIBC.lib'


I looked up LNK2005, and, for some reason, something's already defined. My guess would be that it's the constructor. But, if it's there, how come I got the first error?
Was This Post Helpful? 0
  • +
  • -

#11 Portalboat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 04-December 09

Re: "Default Constructor" error?

Posted 22 January 2010 - 04:17 PM

Bump.
Was This Post Helpful? 0
  • +
  • -

#12 Portalboat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 04-December 09

Re: "Default Constructor" error?

Posted 22 January 2010 - 04:36 PM

TRIPLE POST?
WHHHHHAAAAAAAAAATTTTT?
I've narrowed it down to this line of code, in the header:
entSamusAran(HGE *_hge, InputHandler *_input) : hgeEntityEx(HEL_MIDDLE2, false)
{
	input = _input; 
	hge = _hge;
}


However, when I replace it with
entSamusAran(HGE *_hge, InputHandler *_input) : hgeEntityEx(HEL_MIDDLE2, false)
and move the actual definition of it to the .cpp file, I get a bunch of errors. (Here's a log.)
I'm stuck between a rock and a hard place....
Was This Post Helpful? 0
  • +
  • -

#13 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: "Default Constructor" error?

Posted 22 January 2010 - 05:03 PM

look, we basically can't help you with the information you have provided.

well I could suggest this:
entSamusAran(HGE *_hge, InputHandler *_input) : hgeEntityEx(HEL_MIDDLE2, false), _input(input), hge(_hge) { }


but without knowing anything about the class I have no idea if that is right.

I can give you a little advice: when the compiler complains about a missing semi colon check the line above the line you on -- often that is where the problem lies.

Check the symbols. Many times there is a class that is not defined, or is in another namespace etc.

Basically though -- we have not been helping because there is next to nothing we can do with the information you have provided.
Was This Post Helpful? 0
  • +
  • -

#14 Portalboat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 04-December 09

Re: "Default Constructor" error?

Posted 23 January 2010 - 09:22 AM

Well, what do you need?
Was This Post Helpful? 0
  • +
  • -

#15 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: "Default Constructor" error?

Posted 23 January 2010 - 09:43 AM

Well let see, some things that MIGHT have been helpful right off the bat:

It may have been worth the effort to tell us that you were working with the opal library and were trying to extend the hgeEntityEx -- I have never used the opal library myself, but maybe someone had an example they could have shared.

I personally though that hgeEntityEx was some class you made.

It would be nice to see the class definition (at least the broad stokes) for entSamusAran.

It would have been nice to see the actual line the error occured on (though I think bench correctly diagnosed the "no appropriate default constructor available" problem).

AS for the linker error... what headers are you using in your file? It looks like you are including something twice.

As for the linker errors -- I think you
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2