[DMD 2.064.2]
Hello,
I've been strugling with a solution before bothering you guys
here (again). I have my own complex code but i made a VERY simple
test case to reproduce my problem, here's the code:
private import std.stdio;
class A
{
private const ubyte* data;
private uby
Duhhh! i got the pink avatar by default. That sucks. Pink is just
not my color.
Easy problem in class B: data is null!
On Monday, 9 December 2013 at 02:53:01 UTC, Heinz wrote:
class B
{
private const ubyte* data;
private ubyte[] abc;
this()
{
data = cast(const ubyte*)abc.ptr;
}
Since abc isn't initialized i
On 12/08/2013 07:24 PM, Adam D. Ruppe wrote:
Easy problem in class B: data is null!
On Monday, 9 December 2013 at 02:53:01 UTC, Heinz wrote:
class B
{
private const ubyte* data;
private ubyte[] abc;
this()
{
data = cast(const ubyte*)abc.ptr;
}
Since abc isn't ini
Apparently the OP intended to set it in foo(). If the data is
actually mutable and there really is no way other than going
against the type system, foo() must be called at least once and
can be implemented like this:
public void foo()
{
abc = [1,2,3,4];
cast(ubyte*)data
Wow, i didn't know i could cast out constness from an lvalue.
This is what i needed. I'll try it in my code as soon as i can.
Thanks.
Yep, it compiles and works! By the way, i forgot to call b.foo()
in my example. Thanks for your help guys.