473,382 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Object Destruction in Managed C++ code

Is it true that for a managed Visual C++ object, you can write a destructor
and call that destructor to deallocate that object's memory (just like with
an unmanaged C++ object)?

If this is true, will the Garbage Collector free the object when it runs if
you didn't explicitly free the object yourself?

I've read that Visual C++ is the only .NET language that gives the
programmer control over object lifetimes - C#, J#, and Visual Basic have no
choice but to use the garbage collector. Just wanted to make sure this
statement applies to managed C++ objects (like it does to unmanaged C++
objects).

Thanks!
Craig
Nov 17 '05 #1
2 2200
http://mtaulty.com/blog/archive/2004/06/24/499.aspx

"Craig Whatley" <cr***@aaronmed.com> wrote in message
news:uV**************@TK2MSFTNGP09.phx.gbl...
Is it true that for a managed Visual C++ object, you can write a destructor and call that destructor to deallocate that object's memory (just like with an unmanaged C++ object)?

If this is true, will the Garbage Collector free the object when it runs if you didn't explicitly free the object yourself?

I've read that Visual C++ is the only .NET language that gives the
programmer control over object lifetimes - C#, J#, and Visual Basic have no choice but to use the garbage collector. Just wanted to make sure this
statement applies to managed C++ objects (like it does to unmanaged C++
objects).

Thanks!
Craig

Nov 17 '05 #2
Good information in that posting - thanks!

"Hasani (remove nospam from address)" <hb********@n0sp4m.popstick.com> wrote
in message news:ut**************@TK2MSFTNGP10.phx.gbl...
http://mtaulty.com/blog/archive/2004/06/24/499.aspx

"Craig Whatley" <cr***@aaronmed.com> wrote in message
news:uV**************@TK2MSFTNGP09.phx.gbl...
Is it true that for a managed Visual C++ object, you can write a

destructor
and call that destructor to deallocate that object's memory (just like

with
an unmanaged C++ object)?

If this is true, will the Garbage Collector free the object when it runs

if
you didn't explicitly free the object yourself?

I've read that Visual C++ is the only .NET language that gives the
programmer control over object lifetimes - C#, J#, and Visual Basic have

no
choice but to use the garbage collector. Just wanted to make sure this
statement applies to managed C++ objects (like it does to unmanaged C++
objects).

Thanks!
Craig


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to...
6
by: Squeamz | last post by:
Hello, Say I create a class ("Child") that inherits from another class ("Parent"). Parent's destructor is not virtual. Is there a way I can prevent Parent's destructor from being called when a...
1
by: MAHESH MANDHARE | last post by:
hi To all , I want to know about garbage collector & freeing memory of objects i have writened one sample program and in that i created one destructor something like this using System;...
1
by: Kevin | last post by:
All samples in Micoroft just mention that if a managed type is used as a member in nongc class, for example: gcroot<String*> is used to define a String managed member variable. What if the managed...
5
by: Maxwell | last post by:
Hello, Newbie question here. I have a VS.NET 2003 MC++ (not C++/cli) project where I have a managed class reference in a unmanaged class...simple enough. To keep things short I am for the most...
6
by: shu | last post by:
Is it legal to declare a static instance of an object compiled in a "No CLR support" .obj? I have the next .cpp, in which I mix definition of CTest and declarion of the static var in the same...
15
by: cedgington | last post by:
I wanted to take advantage of the large set of functionality offered by the framework, so for my latest project I'm using managed C++ with .NET v2. I'm using the gcnew operator in two different...
6
by: Pablo | last post by:
Hello, I am writing a windows application using C++ and BorlandBuilder 6 compiler. It is an event driven program and I need to create objects of some classes written by me. One of the classes...
5
by: Frederick Gotham | last post by:
If we have a simple class such as follows: #include <string> struct MyStruct { std::string member; MyStruct(unsigned const i) {
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.