|
-
Feb 20th, 2006, 11:19 AM
#1
Thread Starter
Hyperactive Member
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!
-
Feb 20th, 2006, 11:24 AM
#2
Re: c++ .net
Isn't this more of a C# question than a C++ question?
I can move this to C# is you want.
-
Feb 20th, 2006, 11:28 AM
#3
Thread Starter
Hyperactive Member
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
-
Feb 20th, 2006, 11:30 AM
#4
Re: c++ .net
 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#.
-
Feb 20th, 2006, 11:34 AM
#5
Thread Starter
Hyperactive Member
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
-
Feb 20th, 2006, 11:37 AM
#6
Re: c++ .net
 Originally Posted by chuddy
OK, I am using Visual Studio .NET 2003
Then you are definately using C#
Moved.
-
Feb 20th, 2006, 12:16 PM
#7
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.
-
Feb 20th, 2006, 12:59 PM
#8
Thread Starter
Hyperactive Member
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...
-
Feb 20th, 2006, 01:13 PM
#9
Re: c++ .net
 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++
-
Feb 20th, 2006, 02:08 PM
#10
Re: c++ .net
 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.
-
Feb 20th, 2006, 02:27 PM
#11
Thread Starter
Hyperactive Member
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#
-
Feb 20th, 2006, 02:34 PM
#12
Re: c++ .net
 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!
-
Feb 20th, 2006, 10:55 PM
#13
Re: c++ .net
 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#.
 Originally Posted by Hack
Then you are definately using C#
Moved. 
He's using C++
 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++
 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.
 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#.
-
Feb 21st, 2006, 01:53 AM
#14
Fanatic Member
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.
-
Feb 21st, 2006, 02:23 AM
#15
Re: c++ .net
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|