My value wont hold..... managed code

Started by
1 comment, last by pascalosti 17 years, 7 months ago
The prob is at the end of the code, after i call my function, it doesnt keep the value.

//struct
value struct Vehicle{
public:
	int ^VIN;
	String ^Model;

// function to assign value
void Intro(Vehicle ^A){

	Console::WriteLine("Type 0 if info is not available!");

	Console::WriteLine("Enter VIN Number:");
	String ^tmp = Console::ReadLine();
	A->VIN = Convert::ToInt32(tmp);


// main
// create 2 vehicle types, and initialize (tmp to junk array)

array<Vehicle> ^junk = gcnew array <Vehicle> (Array_Size);

	Vehicle ^tmp;
	tmp = gcnew Vehicle;
	tmp->Tech = gcnew TechInfo;

        tmp->VIN = nullptr;
	tmp->Model = nullptr;

for(int i = 0; (Array_Size-1) > i; i++)
	{
		junk = *tmp;}
        // assign new value to junk
        Intro(junk[0]);
         // here is the problem
        // when i print the value it just prints the initialization value
        // not the new value from the function
	Console::WriteLine(L"Value of VIN is: {0}", junk[0].VIN);



Advertisement
I don't know anything about managed code, but are you positive you're passing the Vehicle into Intro by reference? You store it in the array using *tmp, which gets the value, so I'm thinking you would be passing a copy of the Vehicle in (pass by value), rather than pass by reference.
yeah your correct, took me forever to find that % = & in cli.

This topic is closed to new replies.

Advertisement