|
-
Jun 5th, 2011, 11:37 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Overloading default constructor
Hello,
HTML Code:
g++ (GCC) 4.6.0
I have a class I want to create constructors for. However, as I have structure as part of the class I am running into difficultly since I overloaded the constructor.
I have my default constructor with a initializer list and I have a default constructor for the structure in the class.
However, when I added my overloaded constructor I keep getting the following errors, not sure why:
Code:
error: Floor_plan::Floor_plan()’ cannot be overloaded
error: with ‘Floor_plan::Floor_plan()’
Code:
class Floor_plan
{
private:
unsigned int width;
unsigned int height;
struct floor_size {
unsigned int x;
unsigned int y;
// Constructor
floor_size() {}
floor_size(unsigned int _x, unsigned int _y) : x(_x), y(_y) {}
} floor;
public:
Floor_plan() {}
Floor_plan() : width(1), height(2), floor(10, 20) {}
Floor_plan(unsigned int _width, unsigned int _height, unsigned int _x, unsigned int _y);
~Floor_plan() {};
unsigned int get_floor_width();
unsigned int get_floor_height();
unsigned int get_floor_x_coordinate();
unsigned int get_floor_y_coordinate();
void set_floor_width(unsigned int _width);
void set_floor_height(unsigned int height);
void print_floorplan();
};
Many thanks for any suggestions,
-
Jun 5th, 2011, 03:43 PM
#2
Re: Overloading default constructor
You have two parameterless constructors defined.
The fact that one has an initializer list is irrelevant.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|