Weird Constructor Problem

Started by
5 comments, last by Antheus 16 years, 1 month ago
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
Advertisement
Make sure your class declarations are followed by a semicolon.
class Strike : public Weapon
{
Strike(int nStrength = 3);
} <----- MISSING ;

Quote:Original post by jyk
Make sure your class declarations are followed by a semicolon.


*facepalm*

Lol, thanks :)
EDIT: Fixed everything. Sorry for the inconvience.
There is no type Strike. You want to to new Weapon or create a type called Strike.

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!

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) {}

This topic is closed to new replies.

Advertisement