Sign in to follow this  

Weird Constructor Problem

This topic is 3580 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
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

This topic is 3580 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this