We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,949 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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(""){}
}
2
Contributors
2
Replies
1 Hour
Discussion Span
1 Year Ago
Last Updated
3
Views
Question
Answered
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

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0658 seconds using 2.66MB