Reference and Indirection : ref class « Class « Visual C++ .NET






Reference and Indirection

 
#include "stdafx.h"
using namespace System;

ref class RefClass 
{
public:
    int X;

    RefClass(int x)
    {
        X = x;
    }
};


void main()
{
    RefClass rc(10);
    RefClass ^o;
    
    o = %rc;                
    Console::WriteLine(o->X); 

    rc.X = 20;                
    Console::WriteLine(o->X); 

    int %i = rc.X;            

    i = 30;                   
    Console::WriteLine(o->X); 
}

   
  








Related examples in the same category

1.Stack References
2.class, ref class, value class
3.ref class demo
4.ref class with member string variable
5.ref type