Question

Code fragment 2: template <class T> Tplus slancio, T12) ( Tret: Tet - ol +12 Tetun Tet; } Code fragment 3: Problem 1 (10 poin

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWERS

1. False. We cannot access the total_employees data member yet because, being a static data member, it has to be explicitly defined with a new line of code to be accessible, such as writing int Employee::total_employees = 0; Only then we will be able to do work with it.

2. False. Although we can access the static data member without having to call any object, we still need to use the scope resolution operator to be able to acces it alone.

3. False. Even if it is good practice to access static data members directly from a class without the use of any object, it is syntactically OK to access the data member through a class object as well

4. False. T can be ANY type including a string.

5. False. T can be ANY type including a bool.

6. True. Although T can be any type, it is mandatory for the final type of T to be consistent throughout the function.

7. True. There is no other way to determine the type of T

8. False. m1 cannot access private popcorn functin poppy() function directly. Instead, m1 needs to have an object of popcorn class inside it which can be used to access private poppy() function. This is because not m1, but Movie_goer class has the privilage of accessing private members of the popcorn class through the use of popcorn objects.

9. False. This is because friendship is not mutual. If class Movie_goer is a friend of class popcorn, popcorn is not neccessarily a friend of class Movie_goer

10. False. This is because friendship is not inherited.

Add a comment
Know the answer?
Add Answer to:
Code fragment 2: template <class T> Tplus slancio, T12) ( Tret: Tet - ol +12 Tetun...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In a function template, a generic data type starts with the key word _____ followed by...

    In a function template, a generic data type starts with the key word _____ followed by a parameter name that stands for the data type. template class T function Which of the following blocks is designed to catch any type of exception? catch(){ } catch(...){ } catch(*){ } catch(exception){ } A friend function can only be a regular stand-alone function and can not be a member of another class. True False A function template is an actual function that the...

  • Given the following code fragment public class Point { public int x; // Because these are...

    Given the following code fragment public class Point { public int x; // Because these are public, you can access them public int y; // directly without getters and setters }; public class Rectangle { private Point ll; // the lower left corner of the rectangle private Point ur; // the upper right corner of the rectangle public Point getLLPoint() {return ll;} public Point getURPoint() {return ur;} } (a) Write a method equals for the Rectangle class that takes a...

  • Java Do 68a, 68b, 68c, 68d. Show code & output. public class Employee { private int...

    Java Do 68a, 68b, 68c, 68d. Show code & output. public class Employee { private int id; private String name; private int sal; public Employee(int id, String name, int sal) { super(); this.id = id; this.name = name; this.sal = sal; } public int getid) { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; public void setName(String name) { this.name = name; } public int get Sall) { return sal;...

  • Create the Python code for a program adhering to the following specifications. Write an Employee class...

    Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...

  • C# Hey I am having trouble implementing additonal function to this assignment: Problem: Implement three IComparer classes on Employee - NameComparer, AgeComparer, and PayComparer - that allow Employee...

    C# Hey I am having trouble implementing additonal function to this assignment: Problem: Implement three IComparer classes on Employee - NameComparer, AgeComparer, and PayComparer - that allow Employees to be compared by the Name, Age, and Pay, respectively. Code: Employee.Core.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Employees { partial class Employee { // Field data. private string empName; private int empID; private float currPay; private int empAge; private string empSSN = ""; private string empBene...

  • In Java: Executable Class create an array of Employee objects. You can copy the array you...

    In Java: Executable Class create an array of Employee objects. You can copy the array you made for Chapter 20. create an ArrayList of Employee objects from that array. use an enhanced for loop to print all employees as shown in the sample output. create a TreeMap that uses Strings for keys and Employees as values. this TreeMap should map Employee ID numbers to their associated Employees. process the ArrayList to add elements to this map. print all employees in...

  • Java Do 61a, 61b, 61c, 61d. Show Output and Code. public class Employee { private int...

    Java Do 61a, 61b, 61c, 61d. Show Output and Code. public class Employee { private int id; private String name; private int sal; public Employee(int id, String name, int sal) { super(); this.id = id; this.name = name; this.sal = sal; } public int getid) { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; public void setName(String name) { this.name = name; } public int get Sall) { return sal;...

  • Write a Java class named Employee to meet the requirements described in the UML Class Diagram...

    Write a Java class named Employee to meet the requirements described in the UML Class Diagram below: Note: Code added in the toString cell are not usually included in a regular UML class diagram. This was added so you can understand what I expect from you. If your code compiles cleanly, is defined correctly and functions exactly as required, the expected output of your program will solve the following problem: “An IT company with four departments and a staff strength...

  • Writing 3 Java Classes for Student registration /** * A class which maintains basic information about...

    Writing 3 Java Classes for Student registration /** * A class which maintains basic information about an academic course. */ public class Course {    /** * Attributes. */ private String code; private String title; private String dept; // name of department offering the course private int credits; /** * Constructor. */ public Course(String code, String title, int credits) { // TODO : initialize instance variables, use the static method defined in // Registrar to initialize the dept name variable...

  • //*Manager.java*// public interface Manager { public void handleCrisis(); } _________________________________________________________ /**Employee.java**/ Public abstract class Employee {...

    //*Manager.java*// public interface Manager { public void handleCrisis(); } _________________________________________________________ /**Employee.java**/ Public abstract class Employee { protected final String name; protected final int id; public Employee(String empName, int empId) { name = empName; id = empId; } public Employee() { name = generatedNames[lastGeneratedId]; id = lastGeneratedId++; } public String getName() { return name; } public int getId() { return id; } //returns true if work was successful. otherwise returns false (crisis) public abstract boolean work(); public String toString() { return...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT