value class ValBase
{
public:
int a;
};
ref class RefBase
{
public:
int a;
};
int main(array<System::String ^> ^args)
{
RefBase^ RefBase1 = gcnew RefBase; //LEGAL. Ref type Managed Obj created on CLR heap.
ValBase^ ValBase1 = gcnew ValBase; //LEGAL. Value type Managed Obj created on CLR heap.
RefBase* RefBase2 = new RefBase; //ILLEGAL: new cannot be used on Managed Ref Class
ValBase* ValBase2 = new ValBase; //This compiles okay but where is this "Managed Object" stored ? CLR heap or Native heap ?
}
마지막 할당에서 관리 객체는 어디에 저장됩니까? 나는 C++ CLI에 완전히 익숙하지 않습니다. 또한 값 유형이 코드를 효율적으로 만들기 위해 스택 의미론을 사용해야한다는 것이 사실입니까? 즉 ValBase^ValBase1 = gcnew ValBase 대신 ValBase ValBase1을 사용해야합니다.이 관리 객체는 어디에 저장됩니까?
* 다른 질문입니다. 새로운 질문으로 주저하지 마십시오. –