Question

Create a Namespaces.h header file containing a namespace declaration yourname. The declaration should include a method...

Create a Namespaces.h header file containing a namespace declaration yourname. The declaration should include a method with the signature void message (string, ostream &) that prints a string to the output stream. Create a testNamespaces.cpp that uses the yourname namespace, and invokes the message() method with a message of your choice and cout as input parameters.

  1. NOTE: You should not use the “using namespace” directive in your header file.

Modify Namespaces.h to define PI as 3.1415, and MYNAME as your name, outside of the yourname namespace. Modify your testNamespaces.cpp and add a new message method that has the signature void message(double, ostream &). In addition to the previous call to message, call message with PI and cout as input parameters, and call message with MYNAME and cout as input parameters

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Create a Namespaces.h header file containing a namespace declaration yourname. The declaration should include a method...
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
  • Please add //comments to the header file below. #ifndef CIRCLE_H_INCLUDED #define CIRCLE_H_INCLUDED #include <iostream> using namespace...

    Please add //comments to the header file below. #ifndef CIRCLE_H_INCLUDED #define CIRCLE_H_INCLUDED #include <iostream> using namespace std; class Circle { private: double radius; // declaration of public methods in header file public: Circle() { // default value radius = 1; } void input() { cout << "Enter radius: "; cin >> radius; } void print() { double PI = 3.14159; double area = PI * radius * radius; double circumference = 2 * PI * radius; cout << "Circle with...

  • How to turn this file into a main.cpp, a header which contains the function declaration, and...

    How to turn this file into a main.cpp, a header which contains the function declaration, and a implementation fiel containing the function definition ? #include<iostream> #include<string> #include<iomanip> using namespace std; #define NUM 1 #define MULT 4 void getPi(int iter); int main() {    int it;    cout << "Enter the number of iterations needed to find PI: ";    cin >> it;    while (it < 1) {        cout << "Error!!! Iteration input should be positive." << endl;...

  • #include <fstream> #include <iostream> #include <cstdlib> using namespace std; // Place charcnt prototype (declaration) here int...

    #include <fstream> #include <iostream> #include <cstdlib> using namespace std; // Place charcnt prototype (declaration) here int charcnt(string filename, char ch); int main() { string filename; char ch; int chant = 0; cout << "Enter the name of the input file: "; cin >> filename; cout << endl; cout << "Enter a character: "; cin.ignore(); // ignores newline left in stream after previous input statement cin.get(ch); cout << endl; chcnt = charcnt(filename, ch); cout << "# of " «< ch« "'S:...

  • C++ project we need to create a class for Book and Warehouse using Book.h and Warehouse.h header ...

    C++ project we need to create a class for Book and Warehouse using Book.h and Warehouse.h header files given. Then make a main program using Book and Warehouse to read data from book.dat and have functions to list and find book by isbn Objectives: Class Association and operator overloading This project is a continuation from Project 1. The program should accept the same input data file and support the same list and find operations. You will change the implementation of...

  • // Header code for stack // requesting to create source code using C++ #ifndef Stack_h #define...

    // Header code for stack // requesting to create source code using C++ #ifndef Stack_h #define Stack_h #include <stdio.h> #include <string> #include <iostream> using namespace std; class Stack { public: Stack(); ~Stack(); bool empty(); string top(); void push(const string &val); void pop(); void display(ostream &out); private: class Node { public: string word; Node *next; }; Node *tos; }; #endif Header file provided above. PLS create source code for functions declared in the header. If changes are need no make in...

  • Create a header file timer.h containing the following functions (you can have more functions, but the...

    Create a header file timer.h containing the following functions (you can have more functions, but the below ones are required. Do not modify the given function signatures. // Initialize the timer with the user-provided input void initTimer(ClockType *clock, int minutes, int seconds); // Run the timer -- print out the time each second void runTimer(); // Clean up memory (as needed) void cleanTimer(ClockType *clock); Create a file timer.c and implement (at least) these three functions and any other functions you...

  • For the LinkedList class, create a getter and setter for the private member 'name', constructing your...

    For the LinkedList class, create a getter and setter for the private member 'name', constructing your definitions based upon the following declarations respectively: std::string get_name() const; and void set_name(std::string); In the Main.cpp file, let's test your getter and setter for the LinkedLIst private member 'name'. In the main function, add the following lines of code: cout << ll.get_name() << endl; ll.make_test_list(); ll.set_name("My List"); cout << ll.get_name() << endl; Output should be: Test List My List Compile and run your code;...

  • //Vehicle.h #pragma once #include<iostream> #include"Warranty.h" #include<string> using namespace std; class Vehicle{ protected:    string make; int year;   ...

    //Vehicle.h #pragma once #include<iostream> #include"Warranty.h" #include<string> using namespace std; class Vehicle{ protected:    string make; int year;    double mpg;    Warranty warranty;    static int numOfVehicles; public:    Vehicle();    Vehicle(string s, int y, double m, Warranty warranty);    Vehicle(Vehicle& v);    ~Vehicle();    string getMake();    int getYear();    double getGasMileage();    void setMake(string s);    void setYear(int y);    void setYear(string y);    void setGasMileage(double m);    void setGasMileage(string m);    void displayVehicle();    static int getNumVehicles();    Warranty getWarranty();    void setWarranty(Warranty& ); }; //Vehicle.cpp #include "Vehicle.h" #include <string> Vehicle::Vehicle() {    make = "unknown";    year =...

  • /* BEGIN - DO NOT EDIT CODE */ // File: main.cpp #include "LoginAccount.h" #include "RegisteredLoginAccount.h" #include...

    /* BEGIN - DO NOT EDIT CODE */ // File: main.cpp #include "LoginAccount.h" #include "RegisteredLoginAccount.h" #include "GuestLoginAccount.h" #include <iostream> #include <fstream> #include <string> #include <sstream> using namespace std; //prototypes and constants const int ARRAY_SIZE = 20; using number_of_records_t = int; //Function Declarations. void readAccountsFromFile(ifstream& fin, RegisteredLoginAccount registeredAccounts[], number_of_records_t& registeredLength, GuestLoginAccount guestAccounts[], number_of_records_t& guestLength); bool openFileForInput(ifstream& ifs, const string& filename); bool openFileForOutput(ofstream& ofs, const string& filename); void writeAccountsToFile(ofstream& ofs, RegisteredLoginAccount registeredAccounts[], const number_of_records_t registeredLength, GuestLoginAccount guestAccounts[], const number_of_records_t guestLength); void writeAccountToFile(ofstream&...

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