Results 1 to 15 of 15

Thread: c++ .net

  1. #1

    Thread Starter
    Hyperactive Member chuddy's Avatar
    Join Date
    Oct 2002
    Posts
    333

    c++ .net

    Just beginning to delve into C++ .NET and syntax feels a little different to "regular" c++...

    Code:
    System::String *aString = new System::String("TestString");
    delete aString;
    2 things... the first is that the compiler would not allow me to declare String with the following:

    Code:
    System String aString = "TestString";
    So do I HAVE to use pointers then?

    Secondly... I could not "delete" the pointer... no memory leak?

    Pointer towards a quick tutorial for these kinds of things would be great

    Cheers!

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: c++ .net

    Isn't this more of a C# question than a C++ question?

    I can move this to C# is you want.

  3. #3

    Thread Starter
    Hyperactive Member chuddy's Avatar
    Join Date
    Oct 2002
    Posts
    333

    Re: c++ .net

    Not too sure.. I'm a little confused. As far as I can tell, I am using "C++ .NET"... rather than C#. Is there such a thing? Or am I really using C#? :P

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: c++ .net

    Quote Originally Posted by chuddy
    Not too sure.. I'm a little confused. As far as I can tell, I am using "C++ .NET"... rather than C#. Is there such a thing? Or am I really using C#? :P
    If you are using the .NET version of C, you are using C#.

  5. #5

    Thread Starter
    Hyperactive Member chuddy's Avatar
    Join Date
    Oct 2002
    Posts
    333

    Re: c++ .net

    OK, I am using Visual Studio .NET 2003 and chose a:

    Visual C++ Projects-> .NET -> Windows Forms Application (.NET)

    So I guess it's C#

    Ok, well that's a start then... the right language. Cheers Hack.

    *pls move it

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: c++ .net

    Quote Originally Posted by chuddy
    OK, I am using Visual Studio .NET 2003
    Then you are definately using C#

    Moved.

  7. #7
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: c++ .net

    Actually, there is "Managed C++" for .NET, which can compile regular C++ code as well as .NET code. Unfortunantly we don't have a forum for it since it's hardly ever brought up.
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  8. #8

    Thread Starter
    Hyperactive Member chuddy's Avatar
    Join Date
    Oct 2002
    Posts
    333

    Re: c++ .net

    hmm.. so am I using managed C++ or C#?

    The files that are saved are defaulted as .cpp, but the project has items such as "using namespace System;" which appears to be C# syntax...

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: c++ .net

    Quote Originally Posted by chuddy
    hmm.. so am I using managed C++ or C#?

    The files that are saved are defaulted as .cpp, but the project has items such as "using namespace System;" which appears to be C# syntax...
    If you are using Visual Studio, as you have previously posted, then I suspect you are using C#.

    Here is some info on Managed C++

  10. #10
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: c++ .net

    Quote Originally Posted by chuddy
    Just beginning to delve into C++ .NET and syntax feels a little different to "regular" c++...

    Code:
    System::String *aString = new System::String("TestString");
    delete aString;
    2 things... the first is that the compiler would not allow me to declare String with the following:

    Code:
    System String aString = "TestString";
    So do I HAVE to use pointers then?

    Secondly... I could not "delete" the pointer... no memory leak?

    Pointer towards a quick tutorial for these kinds of things would be great

    Cheers!

    The top code is Managed C++. You have to use a pointer whenever you declare a Managed type in Managed C++. You can create regular variables of non managed types (ie, int, float, any non-gc class you create). You do not need to delete pointers to managed types, since the garbage collector will take care of it.
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  11. #11

    Thread Starter
    Hyperactive Member chuddy's Avatar
    Join Date
    Oct 2002
    Posts
    333

    Re: c++ .net

    Hack & Sunburnt, thanks for the links and information. I think that I AM using managed c++... I think i chose to only install C++ support for my Visual Studio when I installed it.

    Getting a tad complicated with this wierd mix of, effectively, 2 langauges :P I guess it's either that or, more positively, a dip of the toe into c#

  12. #12
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: c++ .net

    Quote Originally Posted by chuddy
    Hack & Sunburnt, thanks for the links and information. I think that I AM using managed c++... I think i chose to only install C++ support for my Visual Studio when I installed it.

    Getting a tad complicated with this wierd mix of, effectively, 2 langauges :P I guess it's either that or, more positively, a dip of the toe into c#
    I had had some experience with C++, but not a whole lot when I got handed a couple of C# projects. (Thank God for these forums. I found everything I needed to know and didn't have to post one single question. ). I think you will find the "transition" to C# fairly easy. I suspect you know C++ one whole heck of a lot better than I do/did, and I really didn't have that much problem. Also, don't dip your toe in....get a running start and jump off the dock into the lake!

  13. #13
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: c++ .net

    Quote Originally Posted by Hack
    If you are using the .NET version of C, you are using C#.
    There is no .Net version of C. There is C, then C++, then Managed C++ and then C#. He is using Managed C++ which is very different from C#.
    Quote Originally Posted by Hack
    Then you are definately using C#

    Moved.
    He's using C++
    Quote Originally Posted by chuddy
    hmm.. so am I using managed C++ or C#?

    The files that are saved are defaulted as .cpp, but the project has items such as "using namespace System;" which appears to be C# syntax...
    That is C++

    Quote Originally Posted by Hack
    If you are using Visual Studio, as you have previously posted, then I suspect you are using C#.

    Here is some info on Managed C++
    This is not true. C# and C++ are very different. He is using C++. Managed C++ but it's still C++. C# is more Java like.
    Quote Originally Posted by Hack
    I had had some experience with C++, but not a whole lot when I got handed a couple of C# projects. (Thank God for these forums. I found everything I needed to know and didn't have to post one single question. ). I think you will find the "transition" to C# fairly easy. I suspect you know C++ one whole heck of a lot better than I do/did, and I really didn't have that much problem. Also, don't dip your toe in....get a running start and jump off the dock into the lake!
    He's not traansitioning to C# though... he is transitioning to Managed C++. There is absoultely no C# involved in this.

    This belongs either in the C++ forum or a new forum for Managed C++ needs to be created. Managed C++ is very different from C#.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  14. #14
    Fanatic Member
    Join Date
    May 2001
    Posts
    837

    Re: c++ .net

    Thank you kasracer! I was getting kind of aggrevated reading this thread having everyone say System::String *aString = new System::String("TestString"); is C# syntax.
    The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.

  15. #15
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: c++ .net

    Quote Originally Posted by DNA7433
    Thank you kasracer! I was getting kind of aggrevated reading this thread having everyone say System::String *aString = new System::String("TestString"); is C# syntax.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

Posting Permissions

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



Click Here to Expand Forum to Full Width