473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 7831
>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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

94
by: John Bailo | last post by:
The c# *return* statement has been bothering me the past few months. I don't like the fact that you can have different code paths in a method and have multiple return statements. To me, it...
14
by: Gama Franco | last post by:
Hi, I'm designing an interface for a shared library, and I would like to know if there is a standard about how to return an object to the user. I will use exceptions to report errors, so there...
6
by: Michael | last post by:
Ok, When can i return by reference? For the sake of simplicity: lets say I have a class MLine: class mv3 { public: float x,y,z;
3
by: b_naick | last post by:
I have a class file in my ASP .NET C# application - defined as follows: namespace ABC { public class BizObj { public Style GetVal(int id) { Style temp = new Style(); // run some db queries...
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
8
by: gregory_may | last post by:
Is it possible to return "nothing" from an Integer function? This seems to give me "0" rather than "nothing". Private Function MyFunction() As Integer Return Nothing End Function
21
by: Jim Langston | last post by:
I'm sure this has been asked a few times, but I'm still not sure. I want to create a function to simplify getting a reference to a CMap in a map. This is what I do now in code: ...
11
by: joey.powell | last post by:
Hello, I have a windows forms application (VS2005) where I need to do the following... 1. Startup with a main form. 2. Have the user to select a file and then bring up a second form modally...
4
by: | last post by:
The output is: 1234 After getline: 1234 After renew: 1234 After retnp: İİİİİİİİİİİİİİİİG After getp: İİİİİİİİİİİİİİİİG -----What happen after renew/retnp call?------- Why not return a true...
68
by: Jim Langston | last post by:
I remember there was a thread a while back that was talking about using the return value of a function as a reference where I had thought the reference would become invalidated because it was a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.