Question: C++: Consider the following C++ program, and one of the C# or Java programs: 1 #include 2 3 template void m(T t) { std::cout

C++: Consider the following C++ program, and one of the C# or Java programs: 1 #include 2 3 template void m(T t) { std::cout 

C++: Consider the following C++ program, and one of the C# or Java programs: 1 #include 2 3 template void m(T t) { std::cout < < "m(T=" < < 4 typeid(T).name() < < ")" < < std::endl; } 5 void m(int i) { std::cout < < "m(int) "; } 6 template void f (T t) { m(t); } 7 8 int main() { 9 10 11 12} C#: f("Hello"); f (123) ; f (4000000000); 1 using System; 2 3 class Program { static void m (T t) { Console.WriteLine($"m (T={typeof (T)})"); } static void m(int i) { Console.WriteLine ("m (int)"); } 4 5 6 static void f (T t) { m(t); } 7 8 9 10 11 static void Main(string[] args) { f("Hello"); f (123); f (4000000000); 12 13} } Java: 1 public class Main { 2 3 4 5 6 7 8 9 10 11} static void m(T t) { System.out.println("m(T)"); } static void m(int i) { System.out.println("m(int)"); } static void f(T t) { m(t); } public static void main(String[] args) { f("Hello"); f (123); f (4000000000L); 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 Physics Questions!