returning constant references from class methods
celavek via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jul 19 05:30:49 PDT 2016
Hi,
I'm trying the following code:
class counter
{
public:
final ulong[char] nucleotide_counts () const
{
return cached_counts;
}
private:
ulong[char] cached_counts;
}
void main()
{
}
I get the following error from the compiler:
Error: cannot implicitly convert expression
(this.cached_counts) of type const(ulong[char]) to ulong[char]
I tried making the class variable constant, I tried the const in
the return type but I can't seem to get it right.
I would like to return a constant reference to the internal
associative array - much like in C++. How would I do that in D?
More information about the Digitalmars-d-learn
mailing list