[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: default constructor and class
From: |
Marco Vassallo |
Subject: |
RE: default constructor and class |
Date: |
Mon, 8 Jul 2013 21:34:58 +0200 |
________________________________
> Date: Mon, 8 Jul 2013 15:27:45 -0400
> Subject: Re: default constructor and class
> From: address@hidden
> To: address@hidden
> CC: address@hidden
>
> On Mon, Jul 8, 2013 at 3:20 PM, Marco Vassallo
> <address@hidden<mailto:address@hidden>> wrote:
> Hi all,
>
> for the fem-fenics pkg I'm creating a new class, and I thus add as
> private members
>
> DECLARE_OCTAVE_ALLOCATOR;
> DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA;
>
> and also the DEFINE counterpart,
>
> which requires the class to have a default constructor (right?)
>
> The problem is that one of the parent class from which I derive my own class
> doesn't provide a default constructor. Example
>
> class B: public octave_base_value, public A
> {
> B(): octave_base_value(), A(), B() {} //error: A() not available
>
> private:
> A my_element;
> DECLARE_OCTAVE_ALLOCATOR;
> DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA;
> }
>
> How can I manage it?
>
> I'm not sure I understand your construct correctly, but is it
> intentional that B inherits from A *and* contains a A object
> (my_element)? Can't you get rid of the inheritance from A and just have
> the my_element member?
>
> Michael.
This class should be a wrapper for the A class.
Even if I avoid deriving from A,
class B: public octave_base_value
{
B(): octave_base_value() {} //error: default constructor for my_element not
available
private:
A my_element;
DECLARE_OCTAVE_ALLOCATOR;
DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA;
}
I still need a constructor for my_elements, and as it is an object of type A I
need to initialize it somehow.
- default constructor and class, Marco Vassallo, 2013/07/08
- Re: default constructor and class, Michael Goffioul, 2013/07/08
- RE: default constructor and class,
Marco Vassallo <=
- Re: default constructor and class, Michael Goffioul, 2013/07/08
- RE: default constructor and class, Marco Vassallo, 2013/07/08
- Re: default constructor and class, Michael Goffioul, 2013/07/08
- RE: default constructor and class, Marco Vassallo, 2013/07/08
- Re: default constructor and class, Michael Goffioul, 2013/07/08
- RE: default constructor and class, Marco Vassallo, 2013/07/08
- Re: default constructor and class, c., 2013/07/08
- Re: default constructor and class, Patrick Noffke, 2013/07/08
- RE: default constructor and class, Marco Vassallo, 2013/07/08
- Re: default constructor and class, Michael Goffioul, 2013/07/08