Re: How do java programmers cope with java missing c++ const?
- From: Thomas Hawtin <usenet@xxxxxxxxxxxxxxxxx>
- Date: Tue, 28 Feb 2006 22:32:22 +0000
VisionSet wrote:
"Jeffrey Schwab" <jeff@xxxxxxxxxxxxxxxx> wrote in message
news:pe0Nf.27304$915.8884@xxxxxxxxxxxxxxxxxxx
Vitaly wrote:C++ const in java is final!!!No, it's not.
final (on fields and locals) is like a subset of const. But then const is like a subset of what you would expect const to be like if you didn't know the peculiarities of C++ (notably if you like pimpls).
class Foo {
private final StringBuilder builder = new StringBuilder();
void methodToCallAnyTimeILike() {
builder.append("Not particularly constant is it really?");
}
}
(My C++ is a bit rusty.)
class ArrayList {
private:
int *const data;
public:
ArrayList(const int length) : data(new int[length]) {
}
~ArrayList() {
delete[] data;
}
void set(const int index, const int value) const {
data[index] = value;
}
int get(const int index) const {
return data[index];
}
};
class Foo {
private:
const ArrayList list;
public:
Foo() : list(1) {
}
void methodToCallAnyTimeILike() const {
list.set(0, "Not particularly constant is it really?" [0]);
}
};
Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
.
- References:
- How do java programmers cope with java missing c++ const?
- From: josh . s17
- Re: How do java programmers cope with java missing c++ const?
- From: Vitaly
- Re: How do java programmers cope with java missing c++ const?
- From: Jeffrey Schwab
- Re: How do java programmers cope with java missing c++ const?
- From: VisionSet
- How do java programmers cope with java missing c++ const?
- Prev by Date: java ide platform a non java language
- Previous by thread: Re: How do java programmers cope with java missing c++ const?
- Next by thread: Re: How do java programmers cope with java missing c++ const?
- Index(es):
Relevant Pages
|