Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

1. Write a C++ template class named Label that takes a single type parameter named E and supports three methods:

a. A constructor that takes a single argument, which is the value of the label, and stores it in' an instance variable named value.
b. getValue: takes no parameters and returns value.
c. selValue: a void method that takes a single parameter of type E and assigns it to value.

2. The following declarations are given.
class Base
{
friend void Other::baz 0;
public:
virtual void foo (Base obj);
protected:
int data;
private:
int size;
};
class Derived : public Base
public:
virtual void foo (Base obj);
};
Given the following partial main program int main (void)

Base *b = new Derived; Base *a = new Base(*b); // insert statement (x) here

For each of the following pairs of statements (x), state whether they are equivalent to each other (where "equivalence" means that the same methods operate on the same parameter values). For each, give a 1-sentence justification for your answer.

i. b->foo(*a);

ii. b->foo(*b);

Suppose that a is an object of class Base, and b is an object of class Derived, and that both are declared globally. For each statement in the kit column of the table below. indicate whether the statement is allowed in the each of the scopes listed at the heads of the table's other columns. Indicate your answers by writing legal or illegal in the tables cells. Statement : In main() In A:foo0 In B:fosx) In friend function Other::baz

Statement

Main()

afoo()

bfoo()1

Other::baz

a.size=10;

 

 

 

 

b.data=20;

 

 

 

 

b.foo(a);

 

 

 

 

3. Complex number s are useful in science net and engineering applications. They have the form a *la. where a is a real number and h is an imaginary number. An example is: 1.0+2.51Xse the following class declaration for complex numbers.

*include
class complex
public :
Complex(double re = O. double im =():
double real();
double imaginary();
void reall( double re ):
void imaginaryls (double im);
private:
double re;
double im ;
};
istream &operater >> (istream&, complex &c);

a. Explain why operator >> is defined as a nonmember function.

b. Write the code for the complexNumber operator >>. Assume that the format of the number read in is a +bi (including the "+" and the "i".

You may assume the presence of a space between the a and the + and between the b and the i. if you wish.

4 a. List out the difference between the below three lines. (3 Marlin)
- int DoSomething() throw();
- int DoSomething() throw(double);
- int DoSomething() throw(.....);

b. An exception handle: wants to re throw the exception might without processing it. How to handle the situation, explain with example?

5. a. Using new operator, show how to allocate memory for an integer Milner to a pointer in order, to make it store 3 rows and 2 columns of integers

b. With an example explain the concept of return by reference and reference parameter.

6. a. Create two classes, Apple and Orange. In Apple. create a constructor that takes an Orange as an argument Create a function that takes an Apple and call that function with an Orange to show that it works, Now make the Apple constructor explicit to demonstrate that the automatic type conversion is thus prevented. Modify the call to your function so that the conversion is made explicitly and thus succeeds.

b. Explain with an example the use of virtual base class in C++.

7. write a C++. program to keep records and perform statistical analysis for a class of 20 quizzes per semester), midterm score, final score, and total score.

The program will prompt the user to choose the operation of records from a menu as shown below:

MENU:

a. Add student records
b. Delete student records
c. Update student records
d. Son students' records by total score

Note: All students records store in a file stream.

8. A stack is a basic data structure, where insertion and deletion of items takes place at one end called top of the stack. The basic concept can be illustrated by thinking of your data as a stack of plates or books where you can only take the top item off the stack in order to remove things from it. A stack is also called a LIFO (Last in First Out) to demonstrate the way it accesses data. There are basically three operations that can be performed on stacks . They are I) inserting an item into a stack (push). 2) deleting an item from the stack (pop). 3) displaying the contents of the stack(peek), Implement it using templates.

a. throw an exception if stack is underflow( stack is empty, is doesn't have any data and trying to remove)

b. throw an exception if stack is overflow ( data inserted more than the army size)

9. You are going to develop software for the accounts department of a company. It should stow the details of the employees. Details should include the salary and profit share of the employees. The company has a policy. Wm; it will calculate the profit share of each employee by dividing the monthly profit of the company with the total number of employees. Consider the change in the number of employees (new appointments and resignations). Create two Class Company and employee

a. Use static members (function(s) and data member(s)).

b. Use appropriate initialization.

c. Use 'Mine function

d. Use class employee as friend to access the details from class company

Data Members can be: number of employees, profit of the company, salary, profit share, number of employees added or left.

Member functions can be: to get salary, to get profit of the company, to calculate a net salary of an employee, to update number employees, to display employee details.

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M91722271
  • Price:- $50

Guranteed 36 Hours Delivery, In Price:- $50

Have any Question?


Related Questions in C/C++

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As