Demonstrates automatic resource management in C++ using RAII and the Owned() method.

ID: 812

See: C++
				
					using uCalcSoftware;

var uc = new uCalc();


// This example is meant only for C++
Console.Write("Evaluating in scope: 20");

				
			
Evaluating in scope: 20
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;

   // Create a uCalc object on the stack.
   uCalc myCalc;
   // Flag it as 'owned' to enable automatic cleanup.
   myCalc.Owned();

   myCalc.DefineVariable("x=10");
   cout << "Evaluating in scope: " << myCalc.Eval("x*2");

   // When 'myCalc' goes out of scope at the end of the block,
   // its destructor is called, which automatically calls Release().


}
				
			
Evaluating in scope: 20
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      
      
      '// This example is meant only for C++
      Console.Write("Evaluating in scope: 20")
      
   End Sub
End Module
				
			
Evaluating in scope: 20