How to use my data type in a function
Hi gang,
I've created an object array from a managed class.
array<MyDataType_Class^> ^Object = gcnew array <MyDataType_Class^> (3);
Object[1] = gcnew MyDataType_Class;
Object[1]->id = 1;
Object[1]->surnmame = "Formen";
TextBox1->AppendText(ConvertToString(Object[1]->surname)); // Outputs "Formen" +
The object works well and outputs expected results. However what i need is :
Calling or using this data type in some other custom functions
Thanks.
PS. referred class
public ref class MyDataType_Class // managed class
{
public:
int id;
String ^surnmame;
MyDataType_Class() : id(0),surname(""){}
}
Related Article: How to use my data type in a function
is a C++ discussion thread by cangan that has 1 reply, was last updated 1 year ago and has been tagged with the keywords: array, class, function, managed, object.
cangan
Newbie Poster
16 posts since Jan 2012
Reputation Points: 11
Solved Threads: 0
Skill Endorsements: 0
I haven't gotten into CLR C++ yet, but I'll take my best shot.
MyDataType_Class ^myFunction(String someName="",int someID=0){
MyDataType_Class ^new Person=gcnew MyDataType_Class();
Person->id=someID * 2; //Multiply by 2 just because
Person->name=someName;
return Person;
}
.
.
.
void SomeOtherFunction(){
MyDataType_Class ^thisPerson=myFunction("Runcible Spoon", 21);
.
.
.
}
DeanMSands3
Posting Whiz
310 posts since Jan 2012
Reputation Points: 80
Solved Threads: 42
Skill Endorsements: 1
I haven't worked it out yet. Please give me some link to look into it.
cangan
Newbie Poster
16 posts since Jan 2012
Reputation Points: 11
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 1 Year Ago by
DeanMSands3