Looking for an alternative to an enum (or any non trivial type)

Hi. I am making a class to manage geometric points, as in [x, y, z]. some languages, such as scripting language 'adobe actionscript' support certain special values such as NaN (or 'not a number'), and I can do things such as
var _some_var:Number = Number.NaN;
the previous sentence is something like assigning null to a pointer. NaN is not a valid value, so I can not operate with a var that has nan as a value.
I want to do something like that in my class, but I can not use a number value and then say, 'this value is never gonna happen by itself, so if the var has that value is because is in nan state. for any value that I choose, if is a valid value, will be enough
to consider it as an invalid alternative. instead of that, the vars are handled in pairs, so for each numeric coordinate, such as x, there is also a bool that says if the numeric value is defined
in each point, there are the x, y and z coordinates, plus defx, defy and defz.
the constructor is something like
point() {
x= 0;
y= 0;
z= 0;
defx = false;
defy=false;
defz=false
and since all vars are private, I use accessors such as
setX(double _x) {
x = _x;
defX = true;
so how do I assign a NaN to a var that has already a value?, or, how do I set the var 'defX' to false again?
since setX(_some_value) is the same as x = _some_value, the idea would be that I could write something like
setX(NaN), and that would 'undefine' X.
since I can overload functions, and create functions with different prototypes for different types of values, even though the functions are called the same way, that's what I am doing.
I had two choices: the first one is (copy paste from my file)
//#ifndef _nan
//#define _nan
//#define NaN "NaN"
//#endif
not the one I chose because it does not seem better than my second choice (that's why it appears as a comment), or does not solve the problem I have with the choices I have thought so far:
(in file 'especiales.h')
#ifndef _especiales
#define _especiales
enum EEspecial {NaN};
#endif
and in the file for the point definition (as inline functions)
void setX(double _x) {
                x = _x;
                defX = true;
        void setX(EEspecial _e) {
                if (_e == NaN)
                    defX = false;
                else
                    throw coordIndefException();
        double getX();
        bool definidoX() {return defX;}
it works, it does not throw an error or there are no syntax problems; but there is a problem in my head. In the previous sentences there are two functions, one that takes a numeric value and sets it in x, and sets x as defined. on that receives not a numeric
value but a special value, that if it turn out to be nan, will unset the x var, and set it as undefined.I checked it with these simple lines:
    geometriaPunto _ensayo;
   try {
        _ensayo.setX(NaN);
        cout << _ensayo.getX() << "\n";
    } catch (exception _e) {
        cout << _e.what() << "\n";
this works fine. if I place a 0 in setX, it will print 0. if I place a NaN in the parenthesis, it will write the exception name. This works fine. But as far as I know, all basic var types, and all enums, also have implicit conversions to numeric values.
so even though it works here, as I understand, telling it setX(0) is the same as setX(NaN) (which would be the implicit conversion of NaN, since is the first value in the enum). none of those are double (because I did not wrote it as setX(0.0) ), so my guess
is that even though it works here, it was just luck, and some other c compile may understand it different, since there is not much difference between function_name(int) or function_name(enum_type)
what would be the best way, most clear way to overload 'setX()' so it does accept a type that can not be confused with a numeric value, yet it does not make my code way more obscure and does not create ambiguity?
tnx

this is the last post I will make on this thread, as I find your answers useless and I already have what I need, but concerning your answers:
"You said it worked for you in your 'adobe actionscript' code - why wouldn't the same technique work in C++ code? Number.NaN is a Number value, and it doesn't prevent you from doing operations in a var that holds that value - but that didn't
seem to concern you before."
have you ever worked with actionscript or did you just post because you had to post anything. yes, I can assign NaN to a numeric var in actionscript, just like I can assign null to a pointer. null is a value (0), if I add something to a var that has null,
it will not have null anymore, if the compiler or the executable don't verify this behavior that should throw an exception. In actionscript, if a var has nan and I add something to it, it will still have nan, because nan is not a value, is a state, and probably
actionscriopt also handles numeric vars with some other types of vars, to make these kind of validations. If I add 1 to garbage, I will still have garbage, and if I choose a random value to be chosen as nan, I or anybody else can not assure this value will
not be the result of a valid operation
2. "Is your question about C#, and not C++? If it is, you are in the wrong forum."
why do you ask, did you see the previous sentences written in c#, or do you still have to answer crap if you don't answer something related to the question. if somebody has been writing things in other languages (including java or the same actionscript,
which support that kind of behavior for properties and accessors), seems logic that I want to maintain that programing style, which will help somebody who also has been writing in those languages and then tries to read this new source, written in c++

Similar Messages

  • My cd drive on my mac w/ itunes is busted, so i'm looking for an alternative way to get mp3 files (large, for an audiobook) from a cd to my iphone. Any suggestions? Thanks

    My cd drive on my mac w/ itunes is busted, so i'm looking for an alternative way to get mp3 files (large, for an audiobook) from a cd to my iphone. Any suggestions? Thanks

    Copy them to a thumb drive using a different computer then use that to transfer them to your machine. Over a network from a machine with a working CD drive...
    What does this have to do with using the iPhone in an enterprise environment?

  • I tried to upgrade Reader and got a 1316 message.  So I thought I would uninstall it and try a new clean download.  Now I can't do anything.  It is looking for Data\Adobe\reader 9.1.cab,  Any suggestions?

    I tried to upgrade Reader and got a 1316 message.  So I thought I would uninstall it and try a new clean download.  Now I can't do anything.  It is looking for Data\Adobe\reader 9.1.cab,  Any suggestions?

    You may also not want to shout (large bold print) when you go to the Reader forum. It irritates a lot of folks and may distract from your question.

  • Looking for a good MAC forum to join.any ideas?

    thanks

    Re: looking for a good MAC forum to join.any ideas?
    a MAC is not the same thing as a Mac.
    MAC
    If your looking for a good Mac forum to join you have already joined it. It is this one.

  • After Mozy's Time Capsule fiasco, looking for cloud alternative

    I've kind of had it with Mozy as an adjunct to Time Capsule (e.g. the fire or burglary scenario). I'm a very new customer, a paying customer. It affected my Time Capsule adversely and Mozy has been zero help (details below for potential Mozy customers who want the grisly details). I'm wondering what other options there are out there to back up to a cloud somewhere and am looking for recommendations from someone who had good recovery experiences with postal-mailed recovered files from a service that will work alongside Time Capsule or maybe even integrate with it in some way.
    If I might digress for an example... Not too long ago I had a hardware failure with a hard drive (that wasn't networked with the Time Capsule), a unit the Apple Store said was a goner and one that resisted a variety of recovery programs, and this great discount repair place I found (Sassinsky) let me send them a portable hard drive along with my iMac's heart. A week later, back came all my files in separate drive partitions on that portable just as my original hard drive had been partitioned, all the data in the right places. I love those guys at Sassinsky. This is what I want from the cloud, too.
    As for Mozy, I've read some user posts of horror stories in how their recovered files came back, scrambled over multiple disks. But in fairness to Mozy, some of those posts are pretty old. So to refocus on my question, are there services out there that will coexist with Time Capsule and that will send you your hundreds of gigabytes of backed up data on a hard drive in a perfect match to your folder structure as it was on your original disk?
    And the postscript for those curious about one Mozy experience, a bit off-topic for this forum, though...
    First, let me say I am heartened to see some Mozy folks (Dave DeLong and Mark Suman) knowledgeable about the Time Capsule conflict and posting here, engaged and really trying to help users. Kudos, Mozy. But I'm disappointed with Mozy Support when I went through channels asking about my problems with Mozy corrupting my Time Capsule. As others have reported, I get the "Time Machine Error. The backup disk image could not be mounted." I had just started with two paid accounts with Mozy. Wow, what an introduction to a new service. I included links to other users' dialogues about the problem, including some discussions.apple.com chatter.
    From Tech Support on Aug. 16 I got a swell response, "We’re sorry about the trouble some of you ran into with this latest version. We’re working quickly to get this issue resolved and expect to release the fix soon." Helpfully adding, "If you uninstall Mozy and reboot, you should be able to use Time Capsule as before. " Of course, this missed the point that in my request for assistance I started off by noting that I had already uninstalled Mozy. Did you notice I said this email came Aug. 16?
    I referred my new Tech Support friend Mubarak to the Aug. 13 Mozy blog entry about new v.1.4.3 that provided a link to the "fix" that already had been released supposedly resolving the Mozy conflict with Time Capsule. You can't expect the tech support folks to keep up on their releases. To his credit, I did get a friendly acknowledgement to my rude missive, a promise two days ago to elevate my inquiry, with no further Mozy response. I understand that I'm asking them about an Apple equipment problem, but darn it, their software caused it. I'm just a little tiny user, two paid accounts, but I think maybe I was wise to go month-to-month and not fall for those discounts with the annual subscription.

    For those who may belated stumble into this thread and have similar questions about cloud alternatives, I found an interesting comparison article at: http://theappleblog.com/2009/07/16/mozy-vs-carbonite-mac-backup-smackdown/
    And with a little more research, I did find that a service mentioned in some posts related to the above review, Blackblaze, does prominently advertise a $189 restore option to a USB drive, which was one of my dreams... see:
    https://www.backblaze.com/internet-backup.html
    Like Mozy, it has exceptions... "backs up everything on your computer except your operating system, applications, temporary files, or those over 4GB." Hmmm... I wonder if a few of my Final Cut Pro projects exceed 4GB? Like Mozy, it will will let you include physically attached external hard drive. Yay.
    Because it requires Intel Macs, I'm thinking that I may keep Mozy for one of my laptops, but switch my main iMac network server to Blackblaze. I've been having problems with Mozy on the laptop, though -- it just stops backing up and doesn't alert me (log shows repeated "churn is not running" and "Could not load version info from server: Error NSUnknownErrorDomain 7." Not very user friendly info. I'll still hold out hope that Apple may do something with Time Machine that would make it easy for vendors to provide a Time Machine compatible service that would integrate seamlessly and adjust fees for all the applications and other memory hog files it would otherwise exclude. I really don't want to have to learn what Mozy churn is, not that my Time Capsule gives me much user-friendly log detail.

  • A long-time Arch user is looking for an alternative

    Hello Arch users,
    I know that this forum is probably not the best place to ask a question like that but I'll try anyways:
    I have been using Archlinux for more than 5 years and I really like the simplicity and the Arch philosophy. However, as I cannot afford to devote a lot of time to maintaining my work station (which Archlinux naturally requires if one relies on a bunch of AUR packages) I have swapped to OS X around a year ago. Please no OS X bashing here, both systems have their advantages and disadvantages which shall be discussed at another place.
    I noticed that for certain tasks a proper Linux is still very handy. Up to now I was just using my former Archlinux notebook every now and then. This means that it occurs that I will not use my Linux box for a couple of months, possibly even a year. With that I get into trouble keeping my system up to date with the rolling release philosophy (due to the huge gaps between two consecutive updates).
    So what I basically want is the Arch-experience without the rolling release feature. It appeared to me that there might possibly be some long-term archive available, where all packages are just available for a long time. If not, can you suggest any other distributions that require little maintenance and are as close to Arch as possible? I really do not want to miss pacman, however, if there is no other way I'd need to install some long-term support Ubuntu...
    Thanks a lot
    Last edited by minus (2013-11-23 09:50:05)

    Thanks for every single reply. It seems I am slowly approaching my best-fit distro
    @andjeng:
    ARM sounds interesting, but two potential problems come to my mind: 1) as described in the wiki, the original ARM has already been closed, if that happens again I won't have a repository and a lot of maintenance work is to be issued. 2) If I will just set my mirrorlist to a fixed date I will not be able to get any security updates (also, see my reply to vostok4).
    @vostok4:
    The problem is that packages in AUR usually require the latest versions of some libraries, so just not applying updates is not possible (that was my first go when I replaced my Arch notebook with a Mac, now it is still being unused as Arch does not work anymore and I don't want to bother fixing the outdated system).
    @ANOKNUSA:
    The tasks I need linux for can be anything, such as being able to read/write/format/re-partition any of my old harddrives or using/compiling software that is available for linux only (or is more stable on linux).
    What I mean by "Arch-experience" is that I can use a simple and powerful package manager like pacman and I can find nearly every thinkable package in AUR (if not, I can create it on my own without a lot of trouble due to the makepkg system). Furthermore, I enjoy(ed) the simplicity (a single configuration file rc.conf where I could configure most of the general system settings, at least before the move to systemd has been carried out, which I dislike as I never had the patience to learn systemd and get the hang of it). When Arch was my only system I also liked that the installation has created a naked linux on my drive that I needed to put clothes on. I guess with converting to a casual linux user I now prefer something that is already ready to use (but I still want to be able to change the clothes).
    I will have a look at CRUX and Darwin as you have suggested.
    I agree that a well-organised filesystem is very important. However, even if one applies the theory meticulously (which I usually don't as I have other priorities when working), the possibility of opening a file without having to click through the folders in a file explorer (or typing the filepath in the terminal) has eased my workflow. I will read your link after I have posted this, though.
    @drcouzelis:
    I have had a look at the Arch-based distros but I think none of them are really what I want (which is a LTS version of Archlinux ). I think I might try out a LTS Mint as soon as I have assembled my new computer.
    @teateawhy:
    I have not used Debian yet, but as far as I understand the release cycles are quite short and there is no LTS of particular releases. In your opinion, why is Debian closer to Arch than the other suggestions?
    Last edited by minus (2013-11-23 22:06:04)

  • Looking for a good group texting app. Any suggestions?

    hey,
    i'm looking for an app that lets me create a group and then have a group conversation with everyone in that group where we can all see the comments of other people. For example, if i need to talk to the family in a group conversation I want to create a group and call it my "my family" And type in "my family" when I want to do a group message. I need it to work on both iOS and android. I welcome any suggestions. Thank you!

    WhatsApp.

  • TS4062 I've done all of these recommended steps.  My problem is that I have a new laptop that I am trying to sync my iPhone (and iPad for that matter) via Wi-Fi but both devices are looking for the old laptop to sync.  Any other suggestions?

    I've done all of these recommended steps.  My problem is that I have a new laptop that I am trying to sync my iPhone (and iPad for that matter) via Wi-Fi but both devices are looking for the old laptop to sync.  My iTunes is version 11.0..3.42, iPhone is 6.1.4, and iPad 6.1.3.  Any suggestions?

    All I had to do was complain.  I synced my iPhone to the Windows machine, checked the other account at iTunes prompting (where no apps had shown up previously), reconnected the iPad, and 140 apps downloaded including the App Store.  I have no idea why.

  • Looking for a good Video intro generator. Any recommendation ?

    Hi there,
    I am looking for some impressive video intro generator & bump into this:
    http://www.reallusion.com/contentstore/cstore_vshowcase.aspx?id=525&CategoryName =iClone
    I bought the iClone4 plus the Motion Montage because I like the part where it will generate the impressive video intro sequence automatically & all I need to do was to drag my pictures & videos into it.
    But, when I used it, this software turns out to be very complicated. When I drag a picture into it, it turns dark immediately !! My guess is that I have to adjust the lighting & a whole series of buttons to get the effect. So, this is too cumbersome & too time consuming for me.
    I need one that can generate an impressive video intro & all I have to do is to select my pictures & video files.
    Any recommendation from experts here ?
    Thanks

    skalicki` wrote:
    I'd never seen any program that could make something like that so easily until I clicked your link! Generally to do that kind of work you need a working knowledge of programs that support editing/modeling in 3D space.
    If nobody else can name another product, you might try the "Contact Us" part of their website:
    http://www.reallusion.com/aboutus.asp#contact
    Yes, I have tried that, all they did was ask me to see their tutorial & manual & forum. But their forum are mostly on iClone4 and not Motion Montage.
    Also, it is too time consuming to learn the iClone4. I bought it because I thought I can produce the impressive video intro by just dragging in my video files & picture files.
    It work to a certain extend but the problem is that the very minute I drag my files into it, it becomes very dark & resolution quality drop to a very bad level, unlike what I see on the sales video.
    I hope others can recommend me another product.
    Thanks

  • I have an 2.4 Mac Book Pro.  I want to wipe it clean and reinstall the Lion OS I bought from the App Store.  I looked for instructions but did not find them any advice where the instructions are would be appreciated.  Thanks

    I am looking for help on how to or where I can find information on how I can clean my hard drive and then reinstall Lion,  Thanks

    Boot from Recovery HD upon startup hold-down keys Command R . Until you see the Apple logo then select language:English.click the Arrow (Next)
    From the OS Utility, select Disk Utility then click Macintosh HD. click the Erase tab on the right side.
    Format:Mac OS Extended(Journaled)
    Name:Macintosh HD
    And click Erase
    Once Erase process is done, close Disk Utility and select the second option in the OS Utility which is Reinstall OS. Let it run. It should take about an hour to complete, this type os installation is internet dependent so somehow the completion of the process depends on internet speed as well.

  • Looking for all in one network printer, know any?

    I am looking to buy a all in one, multi function network printer.
    I have been searching around, calling different vendors, but cant get a clear answer for anybody.
    I need it to print and scan over the network on OS X and Window$.
    Any help would be much appreciated. If you know of anything, please let me know.
    Thank you.

    Hi
    http://www.shopping.hp.com/product/printer/Photosmart/1/storefronts/CC988A%2523A BA
    Installed a few of these just lately. Can't fault them. Good quality at a great price. Built in ethernet 10/100 10-Base T, drivers for Mac and PC, You can Print and Scan to it from both platforms. Drivers compatible with 10.4/10.5/XP/Vista. Good little photocopier as well and supports up to 4 different types/size memory cards. These can be inserted and using the LCD panel (no iinteraction required with Mac or PC) you can print however many photos you want.
    Tony

  • Looking for iTouch 3rd gen. ihome or similar any good ones?

    I got my new itouch 32g, 3rd generation and I have been looking around for an ihome for it.
    I want at least these things:
    speakers
    alarm
    CHARGES the iTouch
    and under like $100 or so.
    Anyone know of anything like this that is compatable with the 3rd generation iThouch?

    Thank you for your input here, but I have tried and tried to find a compatible docking station that DOES indeed charge as well as play, but there are NONE out on the market yet "officially" unless you buy directly from Apple!!
    That comes from Apple themselves.  BB and every other store I've gone too assures you they all will work, and YES, they do play, but they do NOT charge.  According to one piece of advice from Apple too....some of these docks that are not technically for these newer generations can actually cause damage to the iPods themselves internally when you use them.
    Just an FYI that I just got a reply on from another forum site relating to Apple products....

  • I'm looking for a simple, secure password manager. Any thoughts

    Been browsing the Apple store for a password manager.There is a couple highly rated ones.But wanted to expand my search.

    Hi Mark,
    No need to restrict your choice to the preset Pages Templates. Do a web search and choose a Word template. Pages will open Word documents and templates. Or design your own:
    This is a Table I inserted into a blank Pages Word Processing document. Format the date column in Inspector > Table > Format > Cell Format. Select the first Date cell,then drag the fill handle down to increment the dates.
    Regards,
    Ian.

  • I'm looking for a media manager outside of fcpx, any good ones?

    I would like to meta tag and properly organize and categorize all my clips so I can find things under separate searches. Any software available for mac? I know FCPX can do this but I want something outside of FCPX.
    Thank you.

    Hey Tom,
    Thank you for this, I'll check them out. Are you using it?

  • HT1349 I have a ipad an am looking for a good free app to use any idea

    hi we are going on a trip I bought the 30.00 gps am trying to find a good app that is free any ideas their are so many

    an App or a free GPS?
    I use MotionX GPS Drive, love it!!!! Not free for voice turn by turn though.
    Free Apps
    Flipboard
    USA Today
    Podcasts
    Enjoy

Maybe you are looking for

  • Mail Won't Log In To .Mac Accounts

    Hi I get the following error message appearing for the first time - There may be a problem with the mail server or network. Check the settings for account "[email protected]" or try again. The server error encountered was: An SSL error occurred while

  • Ipod won't connect to computer or itunes, help!

    everytime i try to connect my ipod touch to my computer/itunes it doesn't appear

  • How do I get my Adobe Premiere CS5.5 workspace to work

    I am having trouble getting my workspace in Adobe Premiere CS5.5 to open up. Nothing works and I cannot figure out why. Can anyone help? I have tried to reinstall the program and resesting the workspace and it did not help.

  • OWB 10.2.0.1 installation on Oracle Enterprise Linux

    Hello Forum, I am installing OWB 10.2.0.1 on Oracle Enterprise Linux. While installation (creation of OWB reprository) i am getting following exception: A spawned program error. Exception = java.io.IOException: java.io.IOException: ../unix/jvm.sh: ca

  • ESS - Benefits - Open enrollment  (Concurrent employment is enabled)

    We are trying to set up ESS open enrollment. After adding/editing/changing plans --> review enrollment --> Save. On saving, getting an error "rfc_error_system_failure" on the ESS screen. Checked with ST22 for the error details. The name of runtime er