473,372 Members | 883 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,372 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 7829
>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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.