Newbie question
Dune
not.yet at yahoo.com
Tue Nov 28 12:15:14 PST 2006
Hi,
trying to get D into my brain but somehow I'm not in sync yet...
This works (from the docs):
struct Foo {
public:
int data() { return m_data; } // read property
int data(int value) { return m_data = value; } // write property
private:
int m_data;
}
void main() {
Foo f;
f.data = 3; // same as f.data(3);
printf ("%d", f.data + 3); // same as return f.data() + 3;
}
This doesn't:
class Foo {
public:
int data() { return m_data; } // read property
int data(int value) { return m_data = value; } // write property
private:
int m_data;
}
void main() {
Foo f;
f.data = 3; // same as f.data(3);
printf ("%d", f.data + 3); // same as return f.data() + 3;
}
Thanks for any help
Dune
BTW: Maybe I will bother you guys/gals even more... depending on my grasping
skills ;)
More information about the Digitalmars-d-learn
mailing list