Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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) {

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

Students also viewed these Databases questions