Question

Data Structures using C++ Here is the start of a class declaration: class ClassA { public:...

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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

e)

Two of the functions can alter the private member variables of the object that activates the

function.

Add a comment
Know the answer?
Add Answer to:
Data Structures using C++ Here is the start of a class declaration: class ClassA { public:...
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
  • 1. Write TWO different but equivalent statements to do the same thing: use a for statement...

    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...

    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...

  • #code for creature.cpp #include <iostream> using namespace std; class Creature { public: Creature(); void run() const;...

    #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...

    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...

  • Language is C++ Basic principles and theory of structured programming in C++ by implementing the class:...

    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...

  • use C++ Based on the class declaration below, write out the declaration of its default constructor....

    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;

  • C++ class derivedFromTemp: public temp; {public:    void print();    void setZ(double);    double getZ();   ...

    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.

  • C++ write a class “Dog” with a private int field called months and two public member...

    C++ write a class “Dog” with a private int field called months and two public member functions setAge and GetStage. setAge takes as argument monthsToSet and sets the member field months. setAge returns void. getStage is a const member function that takes no argument and returns a string “Puppy” if the dog is less than 9 months old, “Adolescence” if more than 9 and less than 13 months, “Adulthood” if more than 13 and less than 60 months and “Senior”...

  • 8. Suppose class D is derived from class B, and class B has a public member...

    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...

  • 2 Class Vec Message1 2.1 Introduction • Write a class Vec Message1 with the following declaration....

    2 Class Vec Message1 2.1 Introduction • Write a class Vec Message1 with the following declaration. class Vec_Message1 { public: Vec_Message1(); Vec_Message1(int n); Vec_Message1(int n, const Message1 &a); Vec_Message1(const Vec_Message1 &orig); Vec_Message1& operator= (const Vec_Message1 &rhs); ~Vec_Message1(); int capacity() const; int size() const; Message1 front() const; Message1 back() const; void clear(); void pop_back(); void push_back(const Message1 &a); Message1& at(int n); private: void allocate(); void release(); int _capacity; int _size; Message1 * _vec; }; 2.2 allocate() and release() • Examine the...

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