Data Structures using C++
Here is the start of a class declaration:
class ClassA
{
public:
void func1(const ClassA& a);
void func2(const ClassA& a) const;
void func3(ClassA a) const;
...
Which of the three member functions can alter the private member variables of the ClassA object that activates the function?
A. None of the three functions.
B. Only func1.
C. Only func2.
D. Only func3.
E. Only two of the three functions.
e)
Two of the functions can alter the private member variables of the object that activates the
function.
Data Structures using C++ Here is the start of a class declaration: class ClassA { public:...
1. Write TWO different but equivalent statements to do the same thing: use a for statement to print the elements of array numbers by using pointer ptr. 2. Write an expression that uses ptr to copy element 1 (zero-based) of the array to element 3. Do not use numbers in the array in Here is the start of a class declaration: class foo { public: void x(foo f); void y(const foo f); void z(foo f) const; ... 3. Which of...
Multiple Choice Multiple Choice Section 2.1 - 2.2 Introduction to Classes Here is the start of a class declaration: class foo { public: void x(foo f); void y(const foo f); void z(foo f) const; ... Which of the three member functions can alter the PRIVATE member variables of the foo object that activates the function? A. Only x can alter the private member variables of the object that activates the function. B. Only y can alter the private member variables...
C++ Questions. Question 1 What would the function prototype in the class declaration for the following member function look like? void Fractions::showData() { if((num < 0 && denom < 0) || denom < 0) { num = -num; denom = -denom; } cout << num << "/" << denom << endl; } Question 2 What would the function header of the following member function prototype in class Fractions be? Fractions operator+(const Fractions &f2); Question 3 What would the function prototype...
#code for creature.cpp
#include <iostream>
using namespace std;
class Creature {
public:
Creature();
void run() const;
protected:
int distance;
};
Creature::Creature(): distance(10)
{}
void Creature::run() const
{
cout << "running " << distance << "
meters!\n";
}
class Wizard : public Creature {
public:
Wizard();
void hover() const;
private:
int distFactor;
};
Wizard::Wizard() : distFactor(3)
{}
void Wizard::hover() const
{
cout << "hovering " << (distFactor * distance)
<< " meters!\n";
}
//Created new derived class from Creature
class Widget...
c++
Part 1 Consider using the following Card class as a base class to implement a hierarchy of related classes: class Card { public: Card(); Card (string n) ; virtual bool is_expired() const; virtual void print () const; private: string name; Card:: Card() name = ""; Card: :Card (string n) { name = n; Card::is_expired() return false; } Write definitions for each of the following derived classes. Derived Class Data IDcard ID number CallingCard Card number, PIN Driverlicense Expiration date...
This class is missing a number of functions. Rewrite the class declaration to follow best practices, e.g., operators, three important functions, and printing. The functions you write must be const-correct. You do not need to create, an iterator, begin function, or end function. typedef std::string Date; /** * Describe one appointment--as would be listed in * a personal calendar */ class Appointment{ private: Date date; std::string organizer; Attendee* attendeeList; public: /** * Create an empty Appointment */ Appointment() bool...
use C++
Based on the class declaration below, write out the declaration of its default constructor. class BankAccount { public: BankAccount(); // Sets balance to o BankAccount(double initial_balance); // Sets balance to initial_balance // Member functions omitted private: double balance;
Language is C++ Basic principles and theory of structured programming in C++ by implementing the class: Matrix Use these principles and theory to help build and manipulate instances of the class (objects), call member functions Matrix class implementation from the main function file and, in addition, the Matrix class must have its interface(Matrix.h) in a separate file from its implementation (Matrix.cpp). The code in the following files: matrix.h matrix.cpp matrixDriver.h Please use these file names exactly. Summary Create three files...
C++ class derivedFromTemp: public temp; {public: void print(); void setZ(double); double getZ(); double power() const; //return X to power of Z assume getX and setX in temp class. drivedFromTemp(); derivedFromTemp (string, double, double); Private: double z; }; A. Correct errors, if any, after that write difinition of the member function of the class derivedFromTemp.
8. Suppose class D is derived from class B, and class B has a public member function that is virtual whose declaration is virtual void fO:, and another publie member function that is not virtual whose declaration is void g):. Suppose class D has its own version of the two functions void 1() and void gO. Here below is a pointer definition and access to the member functions f) and gO Suppose this is embedded in an otherwise correct and...