New syntax

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rasika WIJAYARATNE

    New syntax

    I am new to C++ so I may be missing something. But doesn't using the new
    syntax ^ instead of * for pointers and 'gcnew' instead of 'new' for example
    make the code very non-portable to unmanaged C++, if the need ever arises?

    Rasika.

    PS. Is it possible to use managed assemblies from unmanaged code?
  • William DePalo [MVP VC++]

    #2
    Re: New syntax

    "Rasika WIJAYARATNE" <RasikaWIJAYARA TNE@discussions .microsoft.com> wrote in
    message news:870ECC48-DE44-4CB1-8969-633955A37684@mi crosoft.com...[color=blue]
    >I am new to C++ so I may be missing something. But doesn't using the new
    > syntax ^ instead of * for pointers and 'gcnew' instead of 'new' for
    > example
    > make the code very non-portable to unmanaged C++, if the need ever arises?[/color]

    Yes. But that is beside the point. Standard C++ does not provide for
    automatic garbage collection. The new syntax is used for manipulating
    grabage-collected objects on the managed heap.

    Regards,
    Will


    Comment

    • William DePalo [MVP VC++]

      #3
      Re: New syntax

      "Rasika WIJAYARATNE" <RasikaWIJAYARA TNE@discussions .microsoft.com> wrote in
      message news:870ECC48-DE44-4CB1-8969-633955A37684@mi crosoft.com...[color=blue]
      >I am new to C++ so I may be missing something. But doesn't using the new
      > syntax ^ instead of * for pointers and 'gcnew' instead of 'new' for
      > example
      > make the code very non-portable to unmanaged C++, if the need ever arises?[/color]

      Yes. But that is beside the point. Standard C++ does not provide for
      automatic garbage collection. The new syntax is used for manipulating
      grabage-collected objects on the managed heap.

      Regards,
      Will


      Comment

      • Carl Daniel [VC++ MVP]

        #4
        Re: New syntax

        Rasika WIJAYARATNE wrote:[color=blue]
        > I am new to C++ so I may be missing something. But doesn't using the
        > new syntax ^ instead of * for pointers and 'gcnew' instead of 'new'
        > for example make the code very non-portable to unmanaged C++, if the
        > need ever arises?[/color]

        Yes.
        [color=blue]
        >
        > Rasika.
        >
        > PS. Is it possible to use managed assemblies from unmanaged code?[/color]

        Yes. If the main program is unmanaged, you can use the .NET hosting APIs to
        host the CLR and managed code in your unmanaged app. If the main program
        can be managed, then VC++ can handle all the interop for you and you can mix
        and match managed/unmanaged code pretty much as you see fit.

        -cd


        Comment

        • Carl Daniel [VC++ MVP]

          #5
          Re: New syntax

          Rasika WIJAYARATNE wrote:[color=blue]
          > I am new to C++ so I may be missing something. But doesn't using the
          > new syntax ^ instead of * for pointers and 'gcnew' instead of 'new'
          > for example make the code very non-portable to unmanaged C++, if the
          > need ever arises?[/color]

          Yes.
          [color=blue]
          >
          > Rasika.
          >
          > PS. Is it possible to use managed assemblies from unmanaged code?[/color]

          Yes. If the main program is unmanaged, you can use the .NET hosting APIs to
          host the CLR and managed code in your unmanaged app. If the main program
          can be managed, then VC++ can handle all the interop for you and you can mix
          and match managed/unmanaged code pretty much as you see fit.

          -cd


          Comment

          • Rasika WIJAYARATNE

            #6
            Re: New syntax

            > and match managed/unmanaged code pretty much as you see fit.

            Can you mix managed and unmanaged code within the same class using C++/CLI?

            Comment

            • Rasika WIJAYARATNE

              #7
              Re: New syntax

              > and match managed/unmanaged code pretty much as you see fit.

              Can you mix managed and unmanaged code within the same class using C++/CLI?

              Comment

              • William DePalo [MVP VC++]

                #8
                Re: New syntax

                "Rasika WIJAYARATNE" <RasikaWIJAYARA TNE@discussions .microsoft.com> wrote in
                message news:2AF5470A-8DB1-48FF-826F-1290A5254565@mi crosoft.com...[color=blue][color=green]
                >> and match managed/unmanaged code pretty much as you see fit.[/color]
                >
                > Can you mix managed and unmanaged code within the same class using
                > C++/CLI?[/color]

                Yes, you can.

                Regards,
                Will


                Comment

                • William DePalo [MVP VC++]

                  #9
                  Re: New syntax

                  "Rasika WIJAYARATNE" <RasikaWIJAYARA TNE@discussions .microsoft.com> wrote in
                  message news:2AF5470A-8DB1-48FF-826F-1290A5254565@mi crosoft.com...[color=blue][color=green]
                  >> and match managed/unmanaged code pretty much as you see fit.[/color]
                  >
                  > Can you mix managed and unmanaged code within the same class using
                  > C++/CLI?[/color]

                  Yes, you can.

                  Regards,
                  Will


                  Comment

                  • Rasika WIJAYARATNE

                    #10
                    Re: New syntax

                    Thank you for your help.

                    "William DePalo [MVP VC++]" wrote:
                    [color=blue]
                    > "Rasika WIJAYARATNE" <RasikaWIJAYARA TNE@discussions .microsoft.com> wrote in
                    > message news:2AF5470A-8DB1-48FF-826F-1290A5254565@mi crosoft.com...[color=green][color=darkred]
                    > >> and match managed/unmanaged code pretty much as you see fit.[/color]
                    > >
                    > > Can you mix managed and unmanaged code within the same class using
                    > > C++/CLI?[/color]
                    >
                    > Yes, you can.
                    >
                    > Regards,
                    > Will
                    >
                    >
                    >[/color]

                    Comment

                    • Rasika WIJAYARATNE

                      #11
                      Re: New syntax

                      Thank you for your help.

                      "William DePalo [MVP VC++]" wrote:
                      [color=blue]
                      > "Rasika WIJAYARATNE" <RasikaWIJAYARA TNE@discussions .microsoft.com> wrote in
                      > message news:2AF5470A-8DB1-48FF-826F-1290A5254565@mi crosoft.com...[color=green][color=darkred]
                      > >> and match managed/unmanaged code pretty much as you see fit.[/color]
                      > >
                      > > Can you mix managed and unmanaged code within the same class using
                      > > C++/CLI?[/color]
                      >
                      > Yes, you can.
                      >
                      > Regards,
                      > Will
                      >
                      >
                      >[/color]

                      Comment

                      • Rasika WIJAYARATNE

                        #12
                        Re: New syntax

                        Thanks for the information.

                        "Carl Daniel [VC++ MVP]" wrote:
                        [color=blue]
                        > Rasika WIJAYARATNE wrote:[color=green]
                        > > I am new to C++ so I may be missing something. But doesn't using the
                        > > new syntax ^ instead of * for pointers and 'gcnew' instead of 'new'
                        > > for example make the code very non-portable to unmanaged C++, if the
                        > > need ever arises?[/color]
                        >
                        > Yes.
                        >[color=green]
                        > >
                        > > Rasika.
                        > >
                        > > PS. Is it possible to use managed assemblies from unmanaged code?[/color]
                        >
                        > Yes. If the main program is unmanaged, you can use the .NET hosting APIs to
                        > host the CLR and managed code in your unmanaged app. If the main program
                        > can be managed, then VC++ can handle all the interop for you and you can mix
                        > and match managed/unmanaged code pretty much as you see fit.
                        >
                        > -cd
                        >
                        >
                        >[/color]

                        Comment

                        • Rasika WIJAYARATNE

                          #13
                          Re: New syntax

                          Thanks for the information.

                          "Carl Daniel [VC++ MVP]" wrote:
                          [color=blue]
                          > Rasika WIJAYARATNE wrote:[color=green]
                          > > I am new to C++ so I may be missing something. But doesn't using the
                          > > new syntax ^ instead of * for pointers and 'gcnew' instead of 'new'
                          > > for example make the code very non-portable to unmanaged C++, if the
                          > > need ever arises?[/color]
                          >
                          > Yes.
                          >[color=green]
                          > >
                          > > Rasika.
                          > >
                          > > PS. Is it possible to use managed assemblies from unmanaged code?[/color]
                          >
                          > Yes. If the main program is unmanaged, you can use the .NET hosting APIs to
                          > host the CLR and managed code in your unmanaged app. If the main program
                          > can be managed, then VC++ can handle all the interop for you and you can mix
                          > and match managed/unmanaged code pretty much as you see fit.
                          >
                          > -cd
                          >
                          >
                          >[/color]

                          Comment

                          Working...