How do I return a NULL reference?

  • Thread starter Thread starter Jeremy Chaney
  • Start date Start date
J

Jeremy Chaney

Forgive me if this is a dumb question. It seems like such a simple thing
that I shouldn't have to ask, but alas, I can't seem to figure it out.

I'm porting some C++ code to MC++ and I have a function that formerly
returned either a valid pointer, or NULL. In MC++, how do I return NULL?
If I try "return NULL;" I get a "cannot convert from 'int' to ..." error.

Thanks,
--Jeremy
 
I'm porting some C++ code to MC++ and I have a function that formerly
returned either a valid pointer, or NULL. In MC++, how do I return NULL?
If I try "return NULL;" I get a "cannot convert from 'int' to ..." error.

Jeremy,

Is nullptr perhaps what you're looking for?

Dave
 
I'm porting some C++ code to MC++ and I have a function that formerly
Is nullptr perhaps what you're looking for?

nullptr is a VC2005 thing that doesn't exist in VC2003.
If the op uses C++/CLI, nullptr will work. With MC++ it won't.

With VC2003 you can use NULL.
e.g. this compiles without problem:
System::String *s = NULL;

OP: What is the function prototype?

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
nullptr did it. Thanks. You would think that that would have been easy
to find. I guess I just looked in all of the wrong places. Thanks,
--Jeremy
 
nullptr did it. Thanks. You would think that that would have been easy
to find. I guess I just looked in all of the wrong places. Thanks,
--Jeremy

Hi,
just for future reference: if you use .NET with Visual C++ 2005, you are
using C++/CLI.
with VC2003 it is called 'Managed Extensions for C++', 'Managed C++' or
simply 'MC++'
these are completely incompatible, so if you are searching for information,
be sure to use the correct name or you'll find lots of information that are
of no use to you anymore.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
Good to know. I had been searching with "MC++" and then translating old
syntax to new syntax. I'll use C++/CLI instead.

Thanks,
--Jeremy
 
Back
Top