Question: please solve those questions Short Answer 41. In the D programming language, a class obey reference semantics but a struct uses value or copy semantics

 please solve those questions Short Answer 41. In the D programming

please solve those questions

Short Answer 41. In the D programming language, a class obey reference semantics but a struct uses value or copy semantics Given the following code what would be printed? The writeln function is similar to Java's System.out.printin methed import std.stdio; struct structy ( void main() ( structy s1; s1.data 0 structy s2; classy c1- new classy c1.data 0 classy c2: int data; class classy ( int data; s2.data 1; writeln(s1.data); c2.data-1: writeln(c1. datal; In both cases we create two objects (two structures; two classes). The code then makes the second one c2 or s2 and copy of the first (-st and c2 - c1.) Then it changes a value in the data variable of the second (c2.data-1; and s2 data-1.). And lastly arines our dena fhom et a s Depending on the meaning of the assignment statement the value printed will be either 1 or a OUTPUT

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!