P
Pixel.to.life
So I have this perfectly fine and running app, that uses managed C++
forms.
Problem#1:
[1] I pass a Bitmap reference to a class, hoping to modify it in one
of the class's methods, so it reflects outside too. Something like
this:
// In a form's scope
Bitmap ^m_Bitmap;
// A separate class
template<typename T> ref class ManagedImageModifier
{
public:
...
...
bool ChangeImage(Bitmap^ iImage)
{
// change iImage here
....
return true;
};
};
This builds fine. The problem is that iImage has a different address
in memory than the reference I pass in. Obviously this means any
change to iImage isnt reflected outside. This came as a surprise
initially to me as I am new to managed programming.
Problem#2:
Anyways, I chose to classify this parameter as a reference variable,
by using 'ref' keyword. Something like this
bool ChangeImage(ref Bitmap^ iImage)
{
// change iImage here
....
return true;
};
And now I get this compile error:
error C2061: syntax error : identifier 'ref'
Note that the same keyword when used to classify the class
ImageModifier wasnt giving me errors.
Any clues on whats going on here????
Thanks a lot!
-P.
forms.
Problem#1:
[1] I pass a Bitmap reference to a class, hoping to modify it in one
of the class's methods, so it reflects outside too. Something like
this:
// In a form's scope
Bitmap ^m_Bitmap;
// A separate class
template<typename T> ref class ManagedImageModifier
{
public:
...
...
bool ChangeImage(Bitmap^ iImage)
{
// change iImage here
....
return true;
};
};
This builds fine. The problem is that iImage has a different address
in memory than the reference I pass in. Obviously this means any
change to iImage isnt reflected outside. This came as a surprise
initially to me as I am new to managed programming.
Problem#2:
Anyways, I chose to classify this parameter as a reference variable,
by using 'ref' keyword. Something like this
bool ChangeImage(ref Bitmap^ iImage)
{
// change iImage here
....
return true;
};
And now I get this compile error:
error C2061: syntax error : identifier 'ref'
Note that the same keyword when used to classify the class
ImageModifier wasnt giving me errors.
Any clues on whats going on here????
Thanks a lot!
-P.