0

How should the class look like?

Hi there ... I'm sitting here in front of an excercise, where one part makes me brooding. Given are some object instantiations - i need to find the fitting class declaration. One line that is given is the following: B b = 'a'; So - how can a object of class B take a single char, without assigning the char to a variable? Thanks for help!

1st Sep 2020, 1:55 PM
Oliver
3 Antworten
+ 3
You can use "=" to call an constructor with a single argument also but the type of the single argument must match the type of the first argument to the constructor. Have a look at it👇 https://www.ibm.com/support/knowledgecenter/SSLTBW_2.2.0/com.ibm.zos.v2r2.cbclx01/cplr387.htm
1st Sep 2020, 2:17 PM
Arsenic
Arsenic - avatar
+ 1
Nailed it! Thanks - maybe i just did not read this point in one of my scripts. :)
1st Sep 2020, 2:52 PM
Oliver
+ 1
Arsenic thx 4 share the link that IBM resource seems to have interesting stuff and good examples, I'll check it
2nd Sep 2020, 2:43 AM
Kiwwi#
Kiwwi# - avatar