dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: C++ .Net Managed Pointers, References, vs. original Pointers, References.

  1. #1
    Join Date
    Jul 2013
    Posts
    17

    C++ .Net Managed Pointers, References, vs. original Pointers, References.

    -If I am programming in C++ .NET in Visual Studio on Windows 10 64 bit,
    and I am submitting method/function parameters to a class that uses
    original C++ pointers and references, however if my parameters
    are declared and happen to be in the type of C++ .NET
    managed pointers (^) and managed references (%),
    do I have to convert my old style pointers and references first?
    Or can I just submit managed pointers and references and rely
    on some form of autoboxing/auto un-boxing for the managed
    pointer or managed reference, "type" information?

    -Correspondingly, if I use a C++ .net reference class that
    has its method parameters declared as
    managed pointers (^) and managed references (%), is
    there a compiled way to tell the .net runtime not not manage
    pointers, references or reference classes, even ones that are declared
    requiring so?

  2. #2
    Join Date
    Feb 2017
    Posts
    344

    Re: C++ .Net Managed Pointers, References, vs. original Pointers, References.

    Teaching someone C++/CLI at a forum is too tedious.

    If you're serious about the language you need to learn it from the ground up. A good place to start is the initial design rationale by Sutter,

    http://www.gotw.ca/publications/C++CLIRationale.pdf

    There are also a few books about the language.

    Good luck!

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,734

    Re: C++ .Net Managed Pointers, References, vs. original Pointers, References.

    Your assemblies need to expose classes and methods that conform to the CLI spec if you expect your c++ .net assemblies to be callable by other .net assemblies. What you do internally is up to you.

  4. #4
    Join Date
    Jul 2013
    Posts
    17

    Re: C++ .Net Managed Pointers, References, vs. original Pointers, References.

    Is there someone who could at least resond to my parameters questions, though, at least?

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,227

    Re: C++ .Net Managed Pointers, References, vs. original Pointers, References.

    Quote Originally Posted by Zachary1234 View Post
    Is there someone who could at least resond to my parameters questions, though, at least?
    Arjay already did it in the post#3.
    Victor Nijegorodov

  6. #6
    Join Date
    Jul 2013
    Posts
    17

    Re: C++ .Net Managed Pointers, References, vs. original Pointers, References.

    -For the sake of the included C++.net supplied library code, in terms of constructor parameters
    or function parameters, that require parameters to be managed pointers and references,
    and not ordinary ones, is there a onetime option to tell the runtime to ignore managed pointers
    and references, (^), (%) and gcnew?

    Even inside compiler library code, or any compiled code which is invoked
    beyond being coded and compiled, after the fact?

  7. #7
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,734

    Re: C++ .Net Managed Pointers, References, vs. original Pointers, References.

    Not sure what you are asking. The only reason to use managed c++ is to access a feature that is only available in .net or if you are writing an assembly that accesses c/c++ dlls but needs to be exposed as a .net assembly. If you aren't doing either of those things, use native c/c++.

  8. #8
    Join Date
    Jul 2013
    Posts
    17

    Re: C++ .Net Managed Pointers, References, vs. original Pointers, References.

    Microsoft .net includes a whole bunch of classes to be used with C++. These include
    domr mathematics, 2d user interface, basic audio, 2d graphics, threads, printing, and some encryption
    support.

    Do the constructors and method calls in any of these (included) basis classes require managed pointers and not
    ordinary ones? Do any of them require managed references and not ordinary references?

    Is there a keyword on an option I can tell the compiler to ignored managed pointers
    and reference syntax, and to default back to just treating them as ordinary ones,
    everywhere that they occur in my code, or in included code that is compiled already?

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,227

    Re: C++ .Net Managed Pointers, References, vs. original Pointers, References.

    Quote Originally Posted by Zachary1234 View Post
    Do the constructors and method calls in any of these (included) basis classes require managed pointers and not
    ordinary ones? Do any of them require managed references and not ordinary references?
    Why not just read the documentation about library, interface and so on you are going to use?
    Victor Nijegorodov

  10. #10
    Join Date
    Jul 2013
    Posts
    17

    Re: C++ .Net Managed Pointers, References, vs. original Pointers, References.

    I have been doing so, but can't find particular answers on these few questions.
    The other thing is that I'm not sure if autoboxing and or auto unboxing occurs before
    or after constructors or interfaces in C++. I can't find answers that hit my
    pointer/reference/mode questions on the head. Help, anybody, please?

  11. #11
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,734

    Re: C++ .Net Managed Pointers, References, vs. original Pointers, References.

    Quote Originally Posted by Zachary1234 View Post
    Microsoft .net includes a whole bunch of classes to be used with C++. These include
    domr mathematics, 2d user interface, basic audio, 2d graphics, threads, printing, and some encryption
    support.

    Do the constructors and method calls in any of these (included) basis classes require managed pointers and not
    ordinary ones? Do any of them require managed references and not ordinary references?

    Is there a keyword on an option I can tell the compiler to ignored managed pointers
    and reference syntax, and to default back to just treating them as ordinary ones,
    everywhere that they occur in my code, or in included code that is compiled already?
    .NET supports multiple languages through the Common Language Infrastructure specification. Assemblies that are part of the .NET framework are CLI compliant so that any assembly can be called by any language regardless of the language it was written in. Given that, the answer to your question is "no", as all public methods of documented assemblies must be CLI compliant.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)