472,096 Members | 1,180 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 software developers and data experts.

How do I return a NULL reference?

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
Feb 17 '07 #1
5 7740
>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
Feb 17 '07 #2
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.

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
br**********************@hotmail.com
Remove only "_nos_pam"
Feb 17 '07 #3
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

David Lowndes wrote:
>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
Feb 18 '07 #4
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
br**********************@hotmail.com
Remove only "_nos_pam"
Feb 18 '07 #5

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

Bruno van Dooren [MVP VC++] wrote:
>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.
Feb 21 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

94 posts views Thread by John Bailo | last post: by
14 posts views Thread by Gama Franco | last post: by
6 posts views Thread by Michael | last post: by
3 posts views Thread by b_naick | last post: by
8 posts views Thread by gregory_may | last post: by
11 posts views Thread by joey.powell | last post: by
4 posts views Thread by | last post: by
68 posts views Thread by Jim Langston | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.