Reference no: EM131220604
Please use codeblocks
List the program and the output on the command line
Eg
#include <iostream>
#include <vector>
using namespace std;
int main()
{
floatjohno = 0.5;
size_t size = 24;
vector<float> array(size);
for(inti=0; i<size; ++i)
{
johno = johno + 1;
array[i] = johno;
cout<<johno;
cout<< " ";
}
}

Q1
Write a class with one virtual function and one non-virtual function. Inherit a new class, make an object of this class, and upcast to a pointer of the base-class type. Use the clock( ) function found in <ctime> to measure the difference between a virtual call and non-virtual call. You'll need to make multiple calls to each function inside your timing loop in order to see the difference.
Q2
Create two classes called Traveler and Pager without default constructors, but with constructors that take an argument of type string, which they simply copy to an internal string variable. For each class, write the correct copy-constructor and assignment operator. Now inherit a class BusinessTraveler from Traveler and give it a member object of type Pager. Write the correct default constructor, a constructor that takes a string argument, a copy-constructor, and an assignment operator.
Q3
Create two identical functions, f1( ) and f2( ). Inline f1( ) and leave f2( ) as an out-of-line function. Use the Standard C Library function clock( ) that is found in <ctime> to mark the starting point and ending points and compare the two functions to see which one is faster. You may need to make repeated calls to the functions inside your timing loop in order to get useful numbers.
Q4
Create a Text class that contains a string object to hold the text of a file. Give it two constructors: a default constructor and a constructor that takes a string argument that is the name of the file to open. When the second constructor is used, open the file and read the contents into the string member object. Add a member function contents( ) to return the string so (for example) it can be printed. In main( ), open a file using Text and print the contents.
Q5
Create a Hen class. Inside this, nest a Nest class. Inside Nest, place an Egg class. Each class should have a display( )member function. In main( ), create an instance of each class and call the display( )function for each one.
Q6
Write a function that takes a char* argument. Using new, dynamically allocate an array of char that is the size of the char array that's passed to the function. Using array indexing, copy the characters from the argument to the dynamically allocated array (don't forget the null terminator) and return the pointer to the copy. In your main( ), test the function by passing a static quoted character array, then take the result of that and pass it back into the function. Print both strings and both pointers so you can see they are different storage. Using delete, clean up all the dynamic storage.
Q7
Create a vector<float> and put the following 25 floating-point numbers into it using a for loop:
0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 10.5 11.5
12.5 13.5 14.5 15.5 16.5 17.5 18.5 19.5 20.5 21.5
22.5 23.5 24.5
Recursive method written by you or taken from web
: What elements should be considered to be included in any recursive method? Discuss these elements using an example (code required) of a recursive method written by you or taken from Web. Try choosing one different from that of any posted thus far.
|
National credit bureaus collect information on peoples
: Suppose that a new privacy law makes it illegal for credit bureaus to collect this information. - What effect would this have on the banking industry?
|
Description of the network technologies and components
: Prepare a Word document that is approximately 3-5 pages in APA format. It should be professional in appearance and suitable for review by network novices. Present the information in laymen's terms.
|
What happens to a cfl when it is encoded
: What happens to a CFL when it is encoded? Is it still necessarily contextfree? (Of course you are supposed to provide an algorithm to construct the grammar if the answer is yes and to provide an example if the answer is no.)
|
Write a class with one virtual and one non-virtual function
: Write a class with one virtual function and one non-virtual function. Inherit a new class, make an object of this class, and upcast to a pointer of the base-class type. Use the clock( ) function found in to measure the difference between a virtual ..
|
Identify why obesity is considered to be a health risk
: Define obesity and identify why it is considered to be a health risk. Identify and discuss one feedback system from either sex and identify the hormones and structures/organs involved.
|
Which two organs do the oviducts effectively connect
: Which two organs do the oviducts effectively connect? In males where specifically are androgens produced? What function is performed by the seminiferous tubules? Name the primary sex organs (gonads) for males and females.
|
Explain the difference between innate and adaptive immunity
: Explain the difference between innate and adaptive immunity. Identify one physical and one chemical barrier of the body to infectious pathogens. What type of white blood cells may become pus following response to an infection?
|
How are indirect costs involved in the preparation
: What are the differences in the ways project managers, accountants, and financial comptrollers perceive the expenses of a project? How are indirect costs involved in the preparation of the budget for a project?
|