On Saturday, 12 July 2014 at 19:42:13 UTC, Ali Çehreli wrote:
Actually, that works too but members must be initialized from
the beginning. The trailing ones are left with .init values:
struct S
{
int i;
string s;
}
void main()
{
auto s = new S(42);
static assert(is (typeof(s) =
On 07/12/2014 12:38 PM, Danyal Zia wrote:
> You can initialize in constructor this(), but you can't initialize
> partial fields of struct when using pointer to struct.
Actually, that works too but members must be initialized from the
beginning. The trailing ones are left with .init values:
st
On Saturday, 12 July 2014 at 19:32:48 UTC, seany wrote:
do I have to initialize all variables of the struct? or may I
also use a this(){} in the struct and initialize only those
which are known at a given moment?
You can initialize in constructor this(), but you can't
initialize partial field
On 07/12/2014 12:32 PM, seany wrote:
> do I have to initialize all variables of the struct?
No. The uninitialized ones get their .init values.
> or may I also use a
> this(){} in the struct and initialize only those which are known at a
> given moment?
That already works with structs. You don'
On 07/12/2014 12:19 PM, seany wrote:
> On Saturday, 12 July 2014 at 19:16:52 UTC, Danyal Zia wrote:
>> On Saturday, 12 July 2014 at 19:09:44 UTC, seany wrote:
>>>arc!(string, string[]) * a;
>>>a.some_var = "hello";
>> "a" has not been instantiated. You are declaring it as a pointer to
>
do I have to initialize all variables of the struct? or may I
also use a this(){} in the struct and initialize only those which
are known at a given moment?
On Saturday, 12 July 2014 at 19:19:28 UTC, seany wrote:
For reasons further down in the software, I need to do this
with a pointer. How do I do it with a pointer, please?
I don't know what are you trying to achieve, but if that's what
you want, you can do:
void MYfunction()
{
auto strArr
On Saturday, 12 July 2014 at 19:09:44 UTC, seany wrote:
Please consider the following
struct arc(T,U)
{
T some_var;
U someother_var;
}
/* things */
class myclass
{
this(){}
~this(){}
void MYfunction()
{
arc!(string, string[]) * a;
a.some_var = "hello";
}
}
void main()
{
On Saturday, 12 July 2014 at 19:16:52 UTC, Danyal Zia wrote:
On Saturday, 12 July 2014 at 19:09:44 UTC, seany wrote:
Please consider the following
struct arc(T,U)
{
T some_var;
U someother_var;
}
/* things */
class myclass
{
this(){}
~this(){}
void MYfunction()
{
arc!(string, string[
Also, (*c).MYfunction() is leading to segmentation fault
sorry, I meant (*a).some_var
not (*c).MYfunction()
Please consider the following
struct arc(T,U)
{
T some_var;
U someother_var;
}
/* things */
class myclass
{
this(){}
~this(){}
void MYfunction()
{
arc!(string, string[]) * a;
a.some_var = "hello";
}
}
void main()
{
c = new myclass();
c.MYfunction();
}
This leads to a
12 matches
Mail list logo