Question

In: Computer Science

  Answer the questions related to the following code:             Class B             {      &nbs

  Answer the questions related to the following code:

            Class B

            {

                        Public:

                                    Void b1();

                        Protected:

                                    Void b2();

            };

            Class A : public B

            {

                        Public:

                                    Void  a1();

                        Protected:

Void  a2();

            };

            Class C: public A  

            {

                        Public:

                                    Void c1();

            };

Void main ()

{

B temp1; A temp2; C temp3;

}   

  1. Name all member functions of all classes visible through temp1 in the main function?
  2. Name all member functions of all classes visible through temp2 in the main function?
  3. Name all member functions of all classes visible through temp3 in the main function?
  4. Which class is the parent of class A?
  5. Which class is the child of class A?

Solutions

Expert Solution

a. The member function visible through temp1 in the main function is b1().

b2() is protected, so it is not visible in main(). All other functions belong to other classes. They cannot be accessed using temp1.

Therefore, b1() is the only member function which is visible through temp1 in the main function.

b. The member functions visible through temp2 in the main function are b1() and a1().

b2() and a2() are protected, so they cannot be accessed in the main.

c1() is the member function of its child class. It cannot be accessed too.

Therefore, b1() and a1() are the member functions which are visible through temp2 in the main function.

c. The member functions visible through temp3 in the main function are b1(), a1() and c1().

b2() and a2() are protected. So, they cannot be accessed in the main.

Therefore, the functions b1(), a1() and c1() are the member functions which are visible through temp3 in the main function.

d. Class B is the parent class of A.

e. Class C is the child class of A.


Related Solutions

Consider the following class and the main method below. Trace the code, then answer the questions...
Consider the following class and the main method below. Trace the code, then answer the questions on the right. public class SomeClass { private String aName; private int aNumber; private boolean amAwesome; public SomeClass(String name, int number){ aName = name; aNumber = number; amAwesome = true; } public SomeClass(String name, int number, boolean awesome){ aName = name; aNumber = number; amAwesome = awesome; } public void methodAwesome(int number){ if(amAwesome) aNumber += number - 5; amAwesome = !amAwesome; } public int...
Answer the following questions based on this codingstrand of DNA:                               &nbs
Answer the following questions based on this codingstrand of DNA:                                                                         5’ GGCCATGACAGAGGAGCAAAAGTTATTGCT 3’ Drennan et al. (1996) identified several mutations in this enzyme that result in methylmalonic acidemia (MMA). One of those mutations is a C to A at base pair 1904 in the coding strand of DNA (bold and italicized in the template strand). Write the unique coding strand of DNA for this patient and highlight the change you made. Write it 5’ to 3’. Write the mRNA sequence...
Use the following information to answer the questions below. NUT                               &nbs
Use the following information to answer the questions below. NUT                                                                                                                               250 Exports                                                                                                                          500 Net increase in foreign ownership of U.S.based nonreserve assets                  400 Net increase in U.S. government’s foreign assets                                                  30 Net increase in U.S. private assets                                                                            250 Investment income received in the U.S.                                                                  200 Net increase in U.S. ownership of official reserve assets                                       20 Imports                                                                                                                           600 Net increase in foreign ownership of U.S. reserve assets                                     100 Investment income paid abroad by the U.S.                                                           300 What is the current account...
Question 3. In the following code, answer these questions: Analyze the code and how it works?...
Question 3. In the following code, answer these questions: Analyze the code and how it works? How can we know if this code has been overwritten? Justify how? #include <stdlib.h> #include <unistd.h> #include <stdio.h> int main(int argc, char **argv) { int changed = 0; char buff[8]; while (changed == 0){ gets(buff); if (changed !=0){ break;} else{     printf("Enter again: ");     continue; } }      printf("the 'changed' variable is modified\n %d", changed); } END of the questions :::::::::::::::::::::::::: :::::::::::::::::::::::::: Submission...
Code of Ethics for Nurses website and related articles. Be sure to address the following questions:...
Code of Ethics for Nurses website and related articles. Be sure to address the following questions: What is this website about? Discuss several specific concepts that you just learned from this website. Are there things that you did know before you reviewed the website? What were they? Did your prior knowledge and what you discovered in your review align? Discuss those things that did or did not align.
Compile and run the following code then answer the following questions: a.) Run this command from...
Compile and run the following code then answer the following questions: a.) Run this command from the shell prompt: ./a.out ls -F Explain, in your own words, why you see the screen output you do and how that output relates to both the content of the program AND the nature of the shell command used to invoke it. Be sure to comment on the pointer arithmetic done inside the line: execvp(*(argv+1), argv+1); b.) Run this command from the shell prompt:...
The Third Question: Answer the following Cases                                   &nbs
The Third Question: Answer the following Cases                                              1- Calculate the required rate of return for Ali Inc., assuming that : Investors expect a 8% rate of inflation in the future. The real risk free rate is 6%. The market risk premium is 10%. The firm has a beta of 2 Its realized rate of return has averaged 30% over the last 10 years. 2) Nader Construction Co. is considering a new inventory system that will cost $1500,000. The system...
Answer 3 of the of these 5 questions AND the questions related to the video in...
Answer 3 of the of these 5 questions AND the questions related to the video in folder on Middle-age: Describe the physical changes that occur during middle age – brain, muscles, senses, skeletal, etc., How do these changes affect daily life and health? Explain the terms “fluid” and “crystallized” intelligence, “”, “menopause” “empty nest syndrome” Describe Erickson’s stage of developmental crisis for middle adulthood. Generativity vs. Stagnation Explain the terms - mid-life crisis, empty nest syndrome, cluttered nest, How do...
5. Answer the following questions related to AFN. a. The following equation is sometimes used to...
5. Answer the following questions related to AFN. a. The following equation is sometimes used to forecast funding requirements: AFN= (A0*/S0)(S) – (L0*/S0)( S) – MS1(1- POR) What key assumption do we make when using this equation? Under what conditions might this assumption not hold? What would be the more general formula for AFN? b. Name five key factors that affect a firm’s external financing requirements. Explain how each one affects the requirements? c. What is meant by the term...
Read the following and answer the related questions that follow it. Auric plc is a mining...
Read the following and answer the related questions that follow it. Auric plc is a mining company, whose main business consists of open cast mining. It has Articles of Association that are in the form of model Articles. The board of directors includes Penny, Howard and Emily. At a recent board meeting, the directors considered an offer from Trek Mines plc to sell land adjoining one of Auric plc’s mining sites for £550,000. The board of Auric plc decided that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT