Sign in to follow this  
Rad94

Weird Constructor Problem

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

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