Question: 2 4 Problem 4. Consider the following C++ program, and one of the C# or Java programs: C++: 1 #include 3 template void m(Tt) {

 2 4 Problem 4. Consider the following C++ program, and oneof the C# or Java programs: C++: 1 #include 3 template void

2 4 Problem 4. Consider the following C++ program, and one of the C# or Java programs: C++: 1 #include 3 template void m(Tt) { std::cout void f(Tt) { m(t); } 8 int main() { f("Hello"); f (123); f (4000000000); 12} 7 9 10 11 C#: 1 using System; 2 6 7 3 class Program { 4 static void m(1 t) { Console.WriteLine($"m(T={typeof (T)})"); } static void m(int i) { Console.WriteLine("m(int)"); } static void f(T t) { m(t); } static void Main(string[] args) { f("Hello"); f (123); f(4000000000); 8 10 11 12 } 1 2 3 4 Java: public class Main { static void m(Tt) { System.out.println("m(T)"); } static void n(int i) { System.out.println("m(int)"); } static void f(Tt) { m(t); } public static void main(String[] args) { f("Hello"); f (123); f (4000000000L); } 11 ) 5 6 7 8 9 10 For the chosen pair of the C++ and C# programs, or the C++ and Java programs, answer the following: 1. What output will be printed by the C++ program, and what output by the second language in the pair? 2. Explain why the C++ program behavior is different (in terms of methods called) from that of the C# or Java one. Why do different methods get called? 3. In C++, C#, or Java, write a generic function that takes 3 arguments of any suitable type T and returns their maximum value

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!