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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Function with optional output

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
couturier Posted - 11/22/2017 : 09:00:52 AM
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

3   L A T E S T    R E P L I E S    (Newest First)
n/a Posted - 12/14/2017 : 10:02:53 AM
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


:)
couturier Posted - 11/23/2017 : 06:53:37 AM
So simple !
thanks
eparent Posted - 11/22/2017 : 11:18:47 AM
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;
}

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000