Jump to content
  • Advertisement
Sign in to follow this  
Rad94

Weird Constructor Problem

This topic is 3792 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 having this really weird constructor problem and need some help. Uarmed_Strike.h
class Strike : public Weapon
{
	Strike(int nStrength = 3);
}


Uarmed_Strike.cpp
#include "Library.h" // Includes "Character.h" which in turn includes "Weapon.h"
#include "Unarmed_Strike.h"

Strike::Strike(int nStrength): Weapon(nStrength) {}


Error message: error C2533: 'Strike::{ctor}' : constructors not allowed a return type

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by jyk
Make sure your class declarations are followed by a semicolon.


*facepalm*

Lol, thanks :)

Share this post


Link to post
Share on other sites
Quote:
Original post by nobodynews
There is no type Strike. You want to to new Weapon or create a type called Strike.


Nah, after pre-processor, the code looks like this:


#include "Library.h" // Includes "Character.h" which in turn includes "Weapon.h"
class Strike : public Weapon
{
Strike(int nStrength = 3);
}

Strike::Strike(int nStrength): Weapon(nStrength) {}




Which in turn translates to:

// Strike::Strike() "returns" 'class Strike : public ....'
class Strike : public Weapon{ Strike(int nStrength = 3);} Strike::Strike(int nStrength): Weapon(nStrength) {}

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!