The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Function with optional output
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

couturier

France
291 Posts

Posted - 11/22/2017 :  09:00:52 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2018 SR0
Operating System: win10

Hi,

I'm trying to write a function with optional output, such as:
void test_null(vector v1, vector& v2 = NULL, vector& v3 = NULL)
{
	v2=2*v1;
	v3=3*v1;
}

with v2 and v3 being calculated only if they are specified.
How to write that kind of function ?

Thanks for your help

eparent

118 Posts

Posted - 11/22/2017 :  11:18:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The following shows how to test if the optional arguments were specified.

void test_null(vector v1, vector& v2 = NULL, vector& v3 = NULL)
{
	if( v2 )
		v2=2*v1;
	if( v3 )
		v3=3*v1;
}
Go to Top of Page

couturier

France
291 Posts

Posted - 11/23/2017 :  06:53:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
So simple !
thanks
Go to Top of Page

n/a

6 Posts

Posted - 12/14/2017 :  10:02:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
hi all, my name is Arsen)) I am a new member here )) thanks for your post , nice to meet you all here, in this web site


:)
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000