473,804 Members | 4,153 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Operator ?

Someone can explain me the meanings of the ? operator applied to
declarations like that i found...

private Point? startPoint;

if i delete the ? the compiler gives me some errors but i don't understand
what's the use of ? in that declaration position...
help me please

Jun 27 '08
38 1395
On Sat, 12 Apr 2008 17:43:08 -0700, Arne Vajhøj <ar**@vajhoej.d kwrote:
If there are close to perfect unit tests it may be OK.

If not then there is the risk of removing some code that was
needed and will cause problems in production.
What makes you think the code is production code in the first place? How
could changing non-production code "cause problems in production"?
Removing stuff that causes compile errors is best case not worst case.
For any of what you wrote to be relevant, you are making a number of broad
assumptions that you are entirely unjustified in making.

There is absolutely nothing in the original post that justifies saying
that the person who wrote that post or what he did is "not smart".
Neither you nor Alain have nearly enough information about the situation
to pass judgment like that.

Get off your high horses. The guy's just asking a question, trying to
learn how the language works. There's no reason for you to make a federal
case out of it.

Pete
Jun 27 '08 #11
On Apr 12, 3:38*pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:

<snip>
You'll find that it can be a little inconvenient, due to the fact that to *
get back to a regular value type you have to explicitly cast from the *
nullable version to the regular version (e.g. "Point point = *
(Point)startPoi nt;"). *This means without the cast, the "nullable" trait*
tends to propagate through your code as you copy values from one
variable *to another. *:)
I don't think I'd want it to behave in any other way - I certainly
wouldn't want an *implicit* conversion to a non-nullable point.

However, I personally tend to use the Value property instead of a cast
- it looks slightly tidier to me. It also makes it more obvious what's
going on if you try to do it to a null value. The cast just compiles
down to a call to Value, so the results are the same, but if you've
got a cast and you see a stack trace with get_Value in, you might
wonder what's going on.

Very much a personal style issue though.

Jon
Jun 27 '08 #12
On Sat, 12 Apr 2008 20:46:05 -0700, Arne Vajhøj <ar**@vajhoej.d kwrote:
Since you did not comment on the argument given:

# because the damage of giving
#"production code" advice to "just for fun code" is insignificant
#to giving "just for fun code" advice to "production code".

then I assume that you do not understand the argument.
You sure love your assumptions, don't you?
Do you want me to it explain it in more detail ?
No. Since there was no need to make any assumptions at all, it doesn't
really matter what your "argument" in favor of the assumption you made
was. Your argument makes the assumption (let's see, looks like you're up
to at least three unwarranted assumptions already) that an assumption was
necessary, when in fact it wasn't. So your "argument" is moot.

That said, the fact is nothing in my reply to you is really for your
benefit. I already have enough experience dealing with you and your
insistence on assuming the worst about the person to whom you're replying
just so that you can make silly criticisms of their posts, that I know
there's nothing I could possibly write that would result in you admitting
a mistake and apologizing.

No, I wrote my reply mainly for the benefit of the OP, so that he
understands that not everyone reading this post is so ready to assume he's
done something stupid. In fact, many of us try to avoid making
assumptions at all. This newsgroup isn't nearly so hostile as one might
have guessed from yours and Alain's posts, and I hope he understands that
now.

Pete
Jun 27 '08 #13
No, I wrote my reply mainly for the benefit of the OP, so that he
understands that not everyone reading this post is so ready to assume
he's done something stupid. In fact, many of us try to avoid making
assumptions at all. This newsgroup isn't nearly so hostile as one might
have guessed from yours and Alain's posts, and I hope he understands
that now.
I didn't make any assumptions at all. Changing code that you don't
understand i usually not a good idea. Whether it's production code or
not doesn't really matter.

The OP asked a question, i answered it correctly. The last sentence was
introduced by the word 'personally'. It shows my opinion on this matter
and i will not discuss it here and I definetly don't want to hurt any
feelings.

But then, thanking for answers in a newsgroup, especially if they
answered your question, should be self-evident. IMHO asking questions
without thanking for responses is more hostile than what i said.

Actually, I probably feel more offended by your reaction than the OP by
my remark.

Alain
Jun 27 '08 #14
Peter Duniho wrote:
But to _assume_ that the OP is doing something stupid is,
well...stupid. As well as insulting to the OP.
I didn't assume anything. I wrote what i think and i'll stick to that
whether you like it or not. Then it was you who attacked arne and me for
our opinions. you even called me stupid. I have no idea who you are and
where you come from but statements like this could get you in trouble -
of course not with me :-)

In a previous post you wrote:
>I mean, you wouldn't want to just delete it and move on. But as part
of trying to understand what the code is doing (which is what the OP
was doing)
Well, this sounds like an assumption to me ... but then, let's finish
this debate before it's getting silly!

Alain
Jun 27 '08 #15
Peter Duniho wrote:
On Sat, 12 Apr 2008 20:46:05 -0700, Arne Vajhøj <ar**@vajhoej.d kwrote:
>Since you did not comment on the argument given:

# because the damage of giving
#"production code" advice to "just for fun code" is insignificant
#to giving "just for fun code" advice to "production code".

then I assume that you do not understand the argument.

You sure love your assumptions, don't you?
>Do you want me to it explain it in more detail ?

No. Since there was no need to make any assumptions at all, it doesn't
really matter what your "argument" in favor of the assumption you made
was.
There are some people that are not interested in arguments.

But you have now confirmed that you did not understand the argument,
because the argument was not about an assumption.
Your argument makes the assumption (let's see, looks like you're
up to at least three unwarranted assumptions already) that an assumption
was necessary, when in fact it wasn't.
I only think I have made 1 assumption: that you did not understand
the argument I gave. And you have just confirmed that to be a true
assumption.

Arne
Jun 27 '08 #16
Ok i'm only a student so i deleted ? operator to discover what code does and
i think it's a good manner to learn programming...t he code was a public
example of WPF program.
Thanks a lot for help.

"MBSoftware " <mb********@ali ce.itha scritto nel messaggio
news:95******** *************** ***********@mic rosoft.com...
Someone can explain me the meanings of the ? operator applied to
declarations like that i found...

private Point? startPoint;

if i delete the ? the compiler gives me some errors but i don't understand
what's the use of ? in that declaration position...
help me please
Jun 27 '08 #17
On Sun, 13 Apr 2008 13:32:40 -0700, MBSoftware <mb********@ali ce.itwrote:
Ok i'm only a student so i deleted ? operator to discover what code does
and i think it's a good manner to learn programming...t he code was a
public example of WPF program.
I think it's a good way to learn too. There's nothing wrong with taking
some sample code and playing around with it, including deleting parts of
it, to see how those changes affect the results (compilation or execution).

On behalf of the newsgroup generally, I'm sorry that others disagree and
felt it necessary to criticize you for what is a perfectly normal and
reasonable approach to learning. Please don't let that discourage you,
and please feel free to post any other questions you may have. Most of us
are in fact here to help, and we look forward to future opportunities to
do so.

Pete
Jun 27 '08 #18
Thanks a lot Pete you're a gentlemen.

"Peter Duniho" <Np*********@nn owslpianmk.comh a scritto nel messaggio
news:op******** *******@petes-computer.local. ..
On Sun, 13 Apr 2008 13:32:40 -0700, MBSoftware <mb********@ali ce.it>
wrote:
>Ok i'm only a student so i deleted ? operator to discover what code does
and i think it's a good manner to learn programming...t he code was a
public example of WPF program.

I think it's a good way to learn too. There's nothing wrong with taking
some sample code and playing around with it, including deleting parts of
it, to see how those changes affect the results (compilation or
execution).

On behalf of the newsgroup generally, I'm sorry that others disagree and
felt it necessary to criticize you for what is a perfectly normal and
reasonable approach to learning. Please don't let that discourage you,
and please feel free to post any other questions you may have. Most of us
are in fact here to help, and we look forward to future opportunities to
do so.

Pete
Jun 27 '08 #19
On Sun, 13 Apr 2008 18:53:49 -0700, Arne Vajhøj <ar**@vajhoej.d kwrote:
Peter Duniho wrote:
>On behalf of the newsgroup generally,

Oh - you are official spokesperson for the newsgroup ...
Not official, no. Of course those readers of the newsgroup who feel that
yours and Alain's behavior was appropriate are free to disavow any
relation to my comments.
[...]
As far as I can tell then you are the only one in this thread that
has been criticizing anyone ...
Yes, it's plain enough that that's as far as you can tell. That's the
problem.

It's a too-common irony that the bully, when told to stop bullying, cries
that he himself is being bullied. The truth is, bullies often have
learned their behavior long ago, internalizing it to the point where they
are literally incapable of seeing the problem with their behavior.

You might consider therapy to help yourself with that. In the meantime,
you're just going to have to deal with being told to stop bullying others
and being bewildered as to why you've been told.

Pete
Jun 27 '08 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
8035
by: Paul Davis | last post by:
I'd like to overload 'comma' to define a concatenation operator for integer-like classes. I've got some first ideas, but I'd appreciate a sanity check. The concatenation operator needs to so something like this: 1) e = (a, b, c, d); // concatenate a,b,c,d into e 2) (a, b, c, d) = e; // get the bits of e into a,b,c, and d For example, in the second case, assume that a,b,c,d represent 2-bit integers, and e represents an 8-bit...
1
3880
by: joesoap | last post by:
Hi can anybody please tell me what is wrong with my ostream operator??? this is the output i get using the 3 attached files. this is the output after i run assignment2 -joesoap #include "BitString.h"
5
3808
by: Jason | last post by:
Hello. I am trying to learn how operator overloading works so I wrote a simple class to help me practice. I understand the basic opertoar overload like + - / *, but when I try to overload more complex operator, I get stuck. Here's a brief description what I want to do. I want to simulate a matrix (2D array) from a 1D array. so what I have so far is something like this: class Matrix
0
1836
by: Martin Magnusson | last post by:
I have defined a number of custom stream buffers with corresponding in and out streams for IO operations in my program, such as IO::output, IO::warning and IO::debug. Now, the debug stream should be disabled in a release build, and to do that efficiently, I suppose I need to overload the << operator. My current implementation of the stream in release mode is posted below. Everything works fine for POD type like bool and int, but the...
3
2961
by: Sensei | last post by:
Hi. I have a problem with a C++ code I can't resolve, or better, I can't see what the problem should be! Here's an excerpt of the incriminated code: === bspalgo.cpp // THAT'S THE BAD FUNCTION!!
6
4431
by: YUY0x7 | last post by:
Hi, I am having a bit of trouble with a specialization of operator<<. Here goes: class MyStream { }; template <typename T> MyStream& operator<<(MyStream& lhs, T const &)
3
18834
by: gugdias | last post by:
I'm coding a simple matrix class, which is resulting in the following error when compiling with g++ 3.4.2 (mingw-special): * declaration of `operator/' as non-function * expected `;' before '<' token <snip> --------------------------------------------------- template <class T> class matriz;
5
2295
by: raylopez99 | last post by:
I need an example of a managed overloaded assignment operator for a reference class, so I can equate two classes A1 and A2, say called ARefClass, in this manner: A1=A2;. For some strange reason my C++.NET 2.0 textbook does not have one. I tried to build one using the format as taught in my regular C++ book, but I keep getting compiler errors. Some errors claim (contrary to my book) that you cannot use a static function, that you must...
8
2491
by: valerij | last post by:
Yes, hi How to write "operator +" and "operator =" functions in a class with a defined constructor? The following code demonstrates that I don't really understand how to do it... I think it has something to do with the compiler calling the destructor twice. Could someone point out where I go wrong? P.S.: The error it gives is "Debug Assertion Failure ....." (at run time) P.P.S: Everything else works just fine (without the use of...
3
3286
by: y-man | last post by:
Hi, I am trying to get an overloaded operator to work inside the class it works on. The situation is something like this: main.cc: #include "object.hh" #include "somefile.hh" object obj, obj2 ;
0
9707
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, 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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10338
jinu1996
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4301
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
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.