C
cppaddict
Hi,
A quick question regarding the use of NULL.
I have a Reader class, which reads from a Display. Reader has two
relevant members for this question:
CharsetCollection
-- a collection of possible Charsets being used by Display
activeCharset
-- the actual Charset being used by Display
The first time a Reader object invokes its findNextChar() method, it
will search every character in each of its Charsets and try to find a
match for the character at the current cursor position in Display. It
will then set activeCharset to the appropriate Charset based on the
search results, so that on future searches only that Charset will be
searched.
Right now, I have the constructor of Reader setting
activeCharset(NULL) in its initialization list.
Then my findNextChar() method looks like this:
char Reader::findNextChar() {
if (activeCharset == NULL) { //compiler errors here
search all Charsets
set activeCharset based on search results
} else {
search only activeCharset
}
}
My question is: What is the right way to do what I am trying to do.
Am I simply using NULL incorrectly? Is my design on the wrong track
altogether?
thanks for any ideas,
cpp
A quick question regarding the use of NULL.
I have a Reader class, which reads from a Display. Reader has two
relevant members for this question:
CharsetCollection
-- a collection of possible Charsets being used by Display
activeCharset
-- the actual Charset being used by Display
The first time a Reader object invokes its findNextChar() method, it
will search every character in each of its Charsets and try to find a
match for the character at the current cursor position in Display. It
will then set activeCharset to the appropriate Charset based on the
search results, so that on future searches only that Charset will be
searched.
Right now, I have the constructor of Reader setting
activeCharset(NULL) in its initialization list.
Then my findNextChar() method looks like this:
char Reader::findNextChar() {
if (activeCharset == NULL) { //compiler errors here
search all Charsets
set activeCharset based on search results
} else {
search only activeCharset
}
}
My question is: What is the right way to do what I am trying to do.
Am I simply using NULL incorrectly? Is my design on the wrong track
altogether?
thanks for any ideas,
cpp