Thread: arrays

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    9

    arrays

    Hello all! I am using MFC with C++ trying to simply add one array to another with the code: totalBalance[count] = totalBalance[count] + payment[count]; but I'm getting the error:
    Code:
    Error	1	error C2676: binary '+' : 'System::Double ^' does not define this operator or a conversion to a type acceptable to the predefined operator	c:\scalderon\mfc windows\ch01\checkingaccount\checkingaccount\Form1.h	309
    Have no idea why it wont work. Any input would be great. Thanks!

  2. #2
    Registered User
    Join Date
    Sep 2010
    Posts
    9
    After Looking at it some more, It looks like I cant perform any type of simple arithmetic on a System:ouble^, So I guess the real question would be: is there a way to get around that or to convert them to a regular double and then perform the operation and the convert back??

  3. #3
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380
    Are you sure that's MFC and not C++/CLI?

  4. #4
    Registered User
    Join Date
    Sep 2010
    Posts
    9
    Quote Originally Posted by BMJ View Post
    Are you sure that's MFC and not C++/CLI?
    Well it's written in C++, I'm not sure why my class is called MFC programming. We use Windows Form Application in C++ but not all the same rules for C++ apply. Normally I can do the arithmetic without problem but I cant and I dont have a clue why.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Because it's C++/CLI. You can't just mix managed and unmanaged types. You're getting burned here.
    And finally, please, it's not written in C++. It's written in C++/CLI. Make a distinction. If your teacher is dumb enough to call it MFC, then slap him/her. It's C++/CLI and not ISO C++.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Sep 2010
    Posts
    9
    Ok, well, I just use the information given. Any suggestions then?

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Nope. Sorry. I don't deal with C++/CLI, so I don't know it.
    Perhaps someone else might, though.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Registered User
    Join Date
    Jul 2010
    Location
    Oklahoma
    Posts
    107
    Stephencalderon,

    I don't mess with C++/CLI aka ECMA 372 either, but this is where I started looking: C++/CLI - Wikipedia, the free encyclopedia. Near the top of the article, there is a topic about the distinction between .Net handles, and C++ pointers. Even later in the article, there is a topic about handles to objects that are passed by reference. The convention has something to do with which portions of the code are subject to automatic garbage collection (remember that stuff from Java, right?) and which portions are not.

    The language specifications are at the bottom of the article. I am confident that the standards discuss the procedure for "de-referencing" the handles, in order to perform operations on the values to which they refer.

    Best Regards,

    New Ink -- Henry
    Kept the text books....
    Went interdisciplinary after college....
    Still looking for a real job since 2005....

    During the interim, I may be reached at ELance, vWorker, FreeLancer, oDesk and WyzAnt.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to create and manipulate Terabyte size Arrays with Win32API
    By KrishnaPG in forum Windows Programming
    Replies: 1
    Last Post: 11-05-2009, 04:08 AM
  2. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  3. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 10:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM