Hi,
I have some code like this....
MyObject ^o = gcnew MyObject();
My2ndObject ^obj2 = o->GetObject();
if( obj2 != NULL )
{
//... do stuff
}
when i compile this I get an error(C2446) no conversion from 'int' to
'My2ndObject ^'
no user-defined-conversion operator available, or
no standard conversion exists from the boxed form of the arithetic type
to the target type
I could do this in VS2003 what do I now need to do now for VS2005?
Thanks
Robin 7 4863
I have some code like this....
>
MyObject ^o = gcnew MyObject();
My2ndObject ^obj2 = o->GetObject();
if( obj2 != NULL )
{
//... do stuff
}
when i compile this I get an error(C2446) no conversion from 'int' to
'My2ndObject ^'
no user-defined-conversion operator available, or
no standard conversion exists from the boxed form of the arithetic type
to the target type
I could do this in VS2003 what do I now need to do now for VS2005?
Hi,
NULL is an pointer sized variable that happens to have a decimal value of 0.
For managed pointers you can use nullptr. Syntax highlighting will color it
blue.
--
Kind regards,
Bruno van Dooren br************* *********@hotma il.com
Remove only "_nos_pam"
Excelent thanks alot I thought that it must be something like that failed to
find that in the documentation when i looked.
Robin
>I have some code like this....
MyObject ^o = gcnew MyObject();
My2ndObject ^obj2 = o->GetObject();
if( obj2 != NULL ) { //... do stuff }
when i compile this I get an error(C2446) no conversion from 'int' to 'My2ndObject ^' no user-defined-conversion operator available, or no standard conversion exists from the boxed form of the arithetic type to the target type
I could do this in VS2003 what do I now need to do now for VS2005?
Hi,
NULL is an pointer sized variable that happens to have a decimal value of
0.
For managed pointers you can use nullptr. Syntax highlighting will color
it blue.
--
Kind regards,
Bruno van Dooren br************* *********@hotma il.com
Remove only "_nos_pam"
Robin Imrie wrote:
Excelent thanks alot I thought that it must be something like that
failed to find that in the documentation when i looked.
FYI, You can use nullptr for native pointers as well.
-cd
"Carl Daniel [VC++ MVP]" wrote:
FYI, You can use nullptr for native pointers as well.
So, is NULL redefined to nullptr somewhere in VC++ headers?
--PA
"Pavel A." <pa*****@NOwrit emeNO.comwrote in message
news:76******** *************** ***********@mic rosoft.com...
"Carl Daniel [VC++ MVP]" wrote:
>FYI, You can use nullptr for native pointers as well.
So, is NULL redefined to nullptr somewhere in VC++ headers?
No, nullptr evaluates to 0 (same as NULL) when used as a native pointer.
>
--PA
Ben Voigt wrote:
No, nullptr evaluates to 0 (same as NULL) when used as a native pointer.
nullptr has a very big advantage to NULL, though. The expression nullptr
implicates that the value is a pointer, while NULL doesn't. Here's an
exmaple:
void f(void*)
{
std::cout << "f(void*)\n ";
}
void f(int)
{
std::cout << "f(int)\n";
}
int main()
{
f(NULL);
f(nullptr);
}
This prints
f(int)
f(void*)
NULL was recognized as an integer (its value is the integer 0
constant), while nullptr is treated as a real pointer (as if it was
(void*)0).
Currently the keyword doesn't work in native projects. It must be a /CLR
project in VC8. However, nullptr is very likely becoming a C++ standard
in 2009. Over time, more and more compilers will support it.
Tom
"Tamas Demjen" <td*****@yahoo. comwrote in message
news:eD******** ********@TK2MSF TNGP02.phx.gbl. ..
Ben Voigt wrote:
>No, nullptr evaluates to 0 (same as NULL) when used as a native pointer.
nullptr has a very big advantage to NULL, though. The expression nullptr
implicates that the value is a pointer, while NULL doesn't. Here's an
exmaple:
Agreed.
But I was responding to Pavel, who hearing that nullptr worked for native
pointers, wondered whether the SDK headers did
#define NULL nullptr This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: SSRoy |
last post by:
I cant use the NULL constant to check a pointer (eg. say Object*) whether it
is valid or not - when I use C++ .NET.
What comes in place of NULL in the managed extension of C++
Pls Help.
Sincerely
Sanjoy Sinharoy
|
by: Andrej Prsa |
last post by:
Hi!
Is there a way to reliably test whether a string was ever declared? E.g.
char *str;
test (str); /* -> no */
str = strdup ("contents");
test (str); /* -> yes */
|
by: junky_fellow |
last post by:
Can 0x0 be a valid virtual address in the address space
of an application ?
If it is valid, then the location pointed by a NULL pointer
is also valid and application should not receive "SIGSEGV"
( i am talking of unix machine ) while trying to read that
location.
Then how can i distinguish between a NULL pointer and an invalid
location ?...
|
by: lihua |
last post by:
Hi, Group!
I got one question here:
We all know that fclose() must be called after file operations to
avoid unexpected errors.But there are really cases when you forget to
do that!Just
like what happens in memory operations, everyone knows the importance
of
freeing the allocated memory, but there do have memory leaks from time
to
|
by: Lev |
last post by:
Hi,
I have an unmanaged pointer to a class that I want to hold in a managed
class. I pass the pointer (from unmanaged code) in the constructor of the
managed class, and at that point it has value. It is stored in a member
variable in my managed class declared as MyObj __nogc* pMyObj. When I try to
retrieve it later, using a function...
| |
by: William F. Kinsley |
last post by:
My understanding is that when I re-compile a existing MFC application with
the /clr switch, that the code generated is managed(with some exceptions)
but that the data isn't, i.e. not garbage collected. I also noticed that
when replaced some of the existing MFC dialogs with managed winforms that
everything is still running in the same app...
|
by: David W |
last post by:
I'm almost tearing my hair out. A colleague claimed that a null reference can exist, like
this:
void f( int& p )
{
printf( "%d\n", p );
}
int main (int argc, char *argv)
{
|
by: Klaus |
last post by:
Hi,
I have an existing VC 6 MFC application which communicates asynchronly with
a VC 2005 managed code dll.
I use an unmanaged base class with virtual functions to access methods in
the MFC application.
Furthermore, I use a pointer to an unmanaged function to jump back into the
managed dll.
The managed part is basically a remoting...
|
by: Alf P. Steinbach |
last post by:
I once suggested in that SomeOne Else(TM) should propose
a string value class that accepted literals and char pointers and so on,
with possible custom deleter, and in case of literal strings just
carrying the original pointer.
In other words, for the simplest usage code:
* no overhead (just carrying a pointer or two), and
* no...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |