473,385 Members | 1,829 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,385 software developers and data experts.

new vs __gc new

Why the following does not compile:
#using <mscorlib.dll>

int main()
{
int __gc *p= __gc new int;
}

while the following compiles?
#using <mscorlib.dll>

int main()
{
int __gc *p= new int;
}

--
Ioannis Vranos
Nov 17 '05 #1
1 1000
Ioannis Vranos wrote:
Why the following does not compile:
#using <mscorlib.dll>

int main()
{
int __gc *p= __gc new int;
}

while the following compiles?
#using <mscorlib.dll>

int main()
{
int __gc *p= new int;
}


I just checked the web and found that since int is a value type, int
__gc * is an interior pointer (a pointer that points to value types) and
not a managed pointer.
However does this imply that we have to call delete explicitly on this
kind of interior pointers, or the object is cleaned by CLR?


--
Ioannis Vranos
Nov 17 '05 #2

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

Similar topics

1
by: TGF | last post by:
Hello, I am calling a Filestream::Read() (i.e. fs->Read(arg1, arg2, arg3)). The problem is I have a pointer to an unsigned char block of memory and would like to fill it with the call to 'Read'....
1
by: Paul Steckler | last post by:
I'm using a managed C++ class that wants an unsigned char __gc as input. Is there a way to easily populate that array from a string constant (or wide string constant, etc.)? I'd like to do...
1
by: Edward Diener | last post by:
In the documentation for a __gc pointer, this explanation occurs: "A __gc pointer to an object of __value class type can either point into the stack or into the common language runtime heap. The...
3
by: Michael Geier | last post by:
Hello, suppose the following structure: __gc struct dfheader { int var1; int var2; unsigned var3; };
1
by: Bern McCarty | last post by:
I am using MEC++ in VC 7.1. I had a method on a __gc object that looked like this: __property System::UInt32 get_MyProperty(void) { System::Byte __pin * pinBytes = &m_byteArray; // entire...
6
by: Lupina | last post by:
#pragma once using namespace System; __gc class CWords { public:
2
by: microsoft | last post by:
Hi All, I am fairly new to Managed C++ extensions. I started trying to implement a interface defined in a C# project, in C++. The problem was with passing value arrays from c# to c++. I found...
3
by: m | last post by:
Hi, I'm reading Microsoft Visual C++ .NET Step by Step, Version 2003 and I found a sentence it says : "you can't have pointers to managed types as members of a __gc class.". Why ? Thanks,...
1
by: Chris | last post by:
Hi, if have a __gc class with a datamember of type : a pointer to a DateTime, but I get a compiler error : __gc class Employee { public: DateTime * m_hiringDate; ==> error : cannot...
5
by: kchui | last post by:
I have a C# interface as: public interface IBar{ void TestParam(ref StringCollection a, ref int b); } And I need to implment it in Managed C++, and I try to implement it as: public __gc...
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.