Question

In: Computer Science

What are the “guard statements” that we put in the .h file of a class definition?...

What are the “guard statements” that we put in the .h file of a class definition? Also tell what each of them do.

______________________________________________________________________________________________

What keywords are used to create, and release dynamic memory?

________________________________________________________________________________________

What is being made constant in the following member function of a Monkey class? Explain what each const is doing.

const Zip& frappa( const Foo& thing ) const;

_________________________________________________________________________________________

Thank you for the explain these problems.

Solutions

Expert Solution

Header Guard's main purpose is to not letting the implemention of same function from header files multiple times in a same program ,like let two header file be A and B and B includes all the Functions for A . Now in a Program both of them are used so , in this case , due to header guards only once functions of A will be included ,not twice.Some comman Header Guards are-

#ifndef,which ends with #endif,Its purpose is to see the macro defined in it should not a pre defination if it does then it does not overwrites the predefination og the macro and thus prevents multiple values of a comman macro.

------------------------------------------------------------------------------------------------------------------------------------------------------

In C++ "new" keyword is use to create and "delete" keyword is used to delete dynamic memory

------------------------------------------------------------------------------------------------------------------------------------------------------

The first "const Zip&" is used to referance a constant pointer variable.

The Middle one is used to make the arguments constent of function frappa.

The last const is used to make the member function of this class Constant.

-------------------------------------------------------------------------------------------------------------------------------------------------------

Apologies if i was not able to explain something properly or if something is incorrect.


Related Solutions

Write a C++ program that design a class definition to be put in a header file...
Write a C++ program that design a class definition to be put in a header file called fizzjazz.h A store sells online FizzJazz which are sound tones made by famous bands. For each FizzJazz, the store wants to keep track of the following attributes: * title - the name of the sound tone * band - Famous band name that created the tone * duration - this is in seconds and may be fractional: examples: 20.0, 34.5 Each attribute will...
Write a C++ program that design a class definition to be put in a header file...
Write a C++ program that design a class definition to be put in a header file called fizzjazz.h A store sells online FizzJazz which are sound tones made by famous bands. For each FizzJazz, the store wants to keep track of the following attributes: * title - the name of the sound tone * band - Famous band name that created the tone * duration - this is in seconds and may be fractional: examples: 20.0, 34.5 Each attribute will...
Write a C++ program that design a class definition to be put in a header file...
Write a C++ program that design a class definition to be put in a header file called fizzjazz.h A store sells online FizzJazz which are sound tones made by famous bands. For each FizzJazz, the store wants to keep track of the following attributes: * title - the name of the sound tone * band - Famous band name that created the tone * duration - this is in seconds and may be fractional: examples: 20.0, 34.5 Each attribute will...
Create a file called grocery.ts. It should have a definition of a class with the obvious...
Create a file called grocery.ts. It should have a definition of a class with the obvious name Grocery. The class should have some basic attributes such as name, quantity, etc. Feel free to add any other attributes you think will be necessary. Add few grocery items to an array of groceries, such as milk, bread, and eggs, along with some quantities (i.e. 3, 6, 11). Display these grocery items as HTML output. The output of this assignment will be grocery.ts...
This class should include .cpp file, .h file and driver.cpp (using the language c++)! Overview of...
This class should include .cpp file, .h file and driver.cpp (using the language c++)! Overview of complex Class The complex class presents the complex number X+Yi, where X and Y are real numbers and i^2 is -1. Typically, X is called a real part and Y is an imaginary part of the complex number. For instance, complex(4.0, 3.0) means 4.0+3.0i. The complex class you will design should have the following features. Constructor Only one constructor with default value for Real...
// FILE: table1.h // // ABSTRACT BASE CLASS: Table //    1. The number of records...
// FILE: table1.h // // ABSTRACT BASE CLASS: Table //    1. The number of records in the Table is stored in total_records // 2. The hashcode function returns a location in the table for the // input key. It calls hash function in functional library. // 3. insert and print are two virtual functions to be overridden // insert: Add a new record into the Table; //           If key is already in the table, do nothing //...
C++ Download Lab10.cpp . In this file, the definition of the class personType has given. Think...
C++ Download Lab10.cpp . In this file, the definition of the class personType has given. Think of the personType as the base class. Lab10.cpp is provided below: #include <iostream> #include <string> using namespace std; // Base class personType class personType { public: void print()const; //Function to output the first name and last name //in the form firstName lastName. void setName(string first, string last); string getFirstName()const; string getLastName()const; personType(string first = "", string last = ""); //Constructor //Sets firstName and lastName...
File Account.java (see 4.1. A Flexible Account Class exercise) contains a definition for a simple bank...
File Account.java (see 4.1. A Flexible Account Class exercise) contains a definition for a simple bank account class withmethods to withdraw, deposit, get the balance and account number, and return a String representation. Note that theconstructor for this class creates a random account number. Save this class to your directory and study it to see how it works.Now modify it to keep track of the total number of deposits and withdrawals (separately) for each day, and the total amountdeposited and...
how we can safe guard global warming?
how we can safe guard global warming?
Create a Java class file for a Car class. In the File menu select New File......
Create a Java class file for a Car class. In the File menu select New File... Under Categories: make sure that Java is selected. Under File Types: make sure that Java Class is selected. Click Next. For Class Name: type Car. For Package: select csci2011.lab7. Click Finish. A text editor window should pop up with the following source code (except with your actual name): csci1011.lab7; /** * * @author Your Name */ public class Car { } Implement the Car...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT