C++ primitive type wrapper

Does C++ have primitive type wrapper?
Not in the standard library, but it provides wrappers for arrays ( std::vector ) and pointers ( std::auto_ptr )
I would like to detect if the value is not NULL, then do some work; otherwise, ignore it. The issue is that NULL is equivalent to 0. Is there a way to detect whether a value is NULL, not zero?

Thanks
In C++, NULL and zero are the same. Something cannot be NULL and not zero or vice versa.
In my logic, I do want to process zero, and ignore NULL. Is there any work-around to achieve this?
NULL is a different name for 0, it's a macro defined like this:
#define NULL 0

Can you be more specific?

NULL means 'pointer pointing to nothing', it's related to pointers not to values
Java has a primitive wrapper e.g. Integer. Suppose
Integer grade;
....
....
if(grade != null){
//do work
}

Since C++ does not have primitive type, I can't do this. But from your explanation about NULL, I *think* I could substitude int* for int wrapper. Could this work?
Java has a primitive wrapper e.g. Integer. Suppose
Integer grade;
....
....
if(grade != null){
//do work
}

Since C++ does not have primitive type, I can't do this. But from your explanation about NULL, I *think* I could substitude int* for int wrapper. Could this work?
You can use pointers and dynamic memory:
1
2
3
4
5
6
7
8
9
10
11
int *grade = NULL;
//...
if ( under certain conditions )
    grade = new int; // ( not NULL )
//...
if ( grade != NULL )
{
   // do work
}
//...
delete grade;

or a magic number:
1
2
3
4
5
6
7
8
9
10
11
const int nil  = someValueYouWillNeverUse;

int grade = nil;
//...
if ( under certain conditions )
    grade = 123;
//...
if ( grade != nil )
{
   // do work
}
Thanks Bazzy.
I may add that the third alternative is to write a class wrapper yourself
Topic archived. No new replies allowed.