Demonstrating that each parsed expression is owned by the uCalc instance that created it.

ID: 604

				
					using uCalcSoftware;

var uc = new uCalc();
// Create two separate uCalc instances
var uc1 = new uCalc();
var uc2 = new uCalc();

// Parse the same expression string in both instances
var expr1 = uc1.Parse("1 + 1");
var expr2 = uc2.Parse("1 + 1");

// Use the .uCalc() method and MemoryIndex to verify ownership
Console.WriteLine($"expr1 belongs to uc1: {expr1.uCalc.MemoryIndex == uc1.MemoryIndex}");
Console.WriteLine($"expr2 belongs to uc2: {expr2.uCalc.MemoryIndex == uc2.MemoryIndex}");
Console.WriteLine($"expr1 does not belong to uc2: {expr1.uCalc.MemoryIndex != uc2.MemoryIndex}");
				
			
expr1 belongs to uc1: True
expr2 belongs to uc2: True
expr1 does not belong to uc2: True
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

#define tf(IsTrue) ((IsTrue) ? "True" : "False")

int main() {
   uCalc uc;
   // Create two separate uCalc instances
   uCalc uc1;
   uCalc uc2;

   // Parse the same expression string in both instances
   auto expr1 = uc1.Parse("1 + 1");
   auto expr2 = uc2.Parse("1 + 1");

   // Use the .uCalc() method and MemoryIndex to verify ownership
   cout << "expr1 belongs to uc1: " << tf(expr1.uCalc().MemoryIndex() == uc1.MemoryIndex()) << endl;
   cout << "expr2 belongs to uc2: " << tf(expr2.uCalc().MemoryIndex() == uc2.MemoryIndex()) << endl;
   cout << "expr1 does not belong to uc2: " << tf(expr1.uCalc().MemoryIndex() != uc2.MemoryIndex()) << endl;
}
				
			
expr1 belongs to uc1: True
expr2 belongs to uc2: True
expr1 does not belong to uc2: True
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// Create two separate uCalc instances
      Dim uc1 As New uCalc()
      Dim uc2 As New uCalc()
      
      '// Parse the same expression string in both instances
      Dim expr1 = uc1.Parse("1 + 1")
      Dim expr2 = uc2.Parse("1 + 1")
      
      '// Use the .uCalc() method and MemoryIndex to verify ownership
      Console.WriteLine($"expr1 belongs to uc1: {expr1.uCalc.MemoryIndex = uc1.MemoryIndex}")
      Console.WriteLine($"expr2 belongs to uc2: {expr2.uCalc.MemoryIndex = uc2.MemoryIndex}")
      Console.WriteLine($"expr1 does not belong to uc2: {expr1.uCalc.MemoryIndex <> uc2.MemoryIndex}")
   End Sub
End Module
				
			
expr1 belongs to uc1: True
expr2 belongs to uc2: True
expr1 does not belong to uc2: True