Question

Circle or mark in some way the member functions that should be constant qualified. class intArray...

  1. Circle or mark in some way the member functions that should be constant qualified.

class intArray {

friend ostream& operator<<(ostream& outStream, intArray& rhs);

public:

    intArray();

    intArray(const intArray&);

    ~intArray();

    void Print();

    int Size();

    int operator[](int);

    intArray operator=(intArray &);

    intArray operator+(intArray);

bool operator==(intArray);

private:

    int size;

    int *data;

};

Homework Answers

Answer #1

//const member function- which ensures that values of data members of class cant be modified
class intArray {

friend ostream& operator<<(ostream& outStream, intArray& rhs);

public:

    intArray(); //cant be declared as const since it initializes values of data members of class

    intArray(const intArray&);//cant be declared as const since it copies data from one object to another object

    ~intArray();

    void Print();//can be declared as const since it only displays the data for object but doesn't modify it

    int Size(); //can be declared as const since it only returns the size

    int operator[](int);//can be declared as const since it only returns the value at particular position

    intArray operator=(intArray &);//cant be declared as const since it copies data from one object to another object

    intArray operator+(intArray);////cant be declared as const since it adds the objects

bool operator==(intArray);//can be declared as const since only comparison of objects is done

private:

    int size;

    int *data;

};
The following member functions can be const qualified

void Print() const
int Size() const
int operator[](int) const
bool operator==(intArray) const

Know the answer?
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
Similar Questions
IN C++ format, Fill in the missing functions, using the concept of operator overloading. code: #include...
IN C++ format, Fill in the missing functions, using the concept of operator overloading. code: #include <string> #include <ostream> using namespace std; class Book { private:     string title;     string author;     unsigned isbn;     double price; public: /**Constructors*/    Book();    Book(string t, string a, unsigned i, double p);     /**Access Functions*/     string get_title();     string get_author();     unsigned get_isbn();     double get_price();     /**Manipulation Procedures*/    void set_title(string t);     void set_author(string a);     void set_isbn(unsigned...
IntNode class I am providing the IntNode class you are required to use. Place this class...
IntNode class I am providing the IntNode class you are required to use. Place this class definition within the IntList.h file exactly as is. Make sure you place it above the definition of your IntList class. Notice that you will not code an implementation file for the IntNode class. The IntNode constructor has been defined inline (within the class declaration). Do not write any other functions for the IntNode class. Use as is. struct IntNode { int data; IntNode *next;...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 565 Error 2 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 761 I need this code to COMPILE and RUN, but I cannot get rid of this error. Please Help!! #include #include #include #include using namespace std; enum contactGroupType {// used in extPersonType FAMILY, FRIEND, BUSINESS, UNFILLED }; class addressType { private:...
#ifndef BAG_H #define BAG_H #include <cstdlib> // Provides size_t using namespace std; class bag { public:...
#ifndef BAG_H #define BAG_H #include <cstdlib> // Provides size_t using namespace std; class bag { public: // TYPEDEFS and MEMBER CONSTANTS typedef int value_type; typedef std::size_t size_type; static const size_type CAPACITY = 30; // CONSTRUCTOR bag() {used = 0;} // MODIFICATION MEMBER FUNCTIONS size_type erase(const value_type& target); bool erase_one(const value_type& target); void insert(const value_type& entry); void operator +=(const bag& addend); void sort(const bag& b); //Sort the array in the bag object // CONSTANT MEMBER FUNCTIONS size_type size( ) const {...
How do I fix my error of binding on line 74? #include <iostream> #include <fstream> #include...
How do I fix my error of binding on line 74? #include <iostream> #include <fstream> #include <cctype> #include <cstring> #include <iomanip> using namespace std; #include "AvlTree.h" class WordCount { public:     char *word;     int *lines;     int count;     int size;     bool operator<(const WordCount &rhs) const {return strcmp(word, rhs.word) < 0;}     bool operator!= (const WordCount &rhs) const {return strcmp(word, rhs.word) != 0;}     WordCount():lines(NULL), count(0), size(0) {word = new char[1]; word[0] = '\0';}     friend ostream& operator<<...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input operator>> a bigint in the following manner: Read in any number of digits [0-9] until a semi colon ";" is encountered. The number may span over multiple lines. You can assume the input is valid. Overload the operator+ so that it adds two bigint together. Overload the subscript operator[]. It should return the i-th digit, where i is the 10^i position. So the first...
Add a second data member (another int) to the class ObjX. Then in main assign a...
Add a second data member (another int) to the class ObjX. Then in main assign a value to the new variable and print it. class ObjX { // No "static" keyword for either member. int i; void print () { System.out.println ("i=" + i); } } public class DynamicExample { public static void main (String[] argv) { // First create an instance, which allocates space from the heap. ObjX x = new ObjX (); // Now access members via the...
do (iii) and (iv) (i) This is a simple Point class interface file whose objects represent...
do (iii) and (iv) (i) This is a simple Point class interface file whose objects represent points in the cartesian plane #include <iostream> using namespace std; class Point { public:     Point()      // default constructor         Point(double x, double y); // another constructor         double x() const; // get function, return _x         double y() const; // get function, return _y private:         double _x, _y; }; (ii) Here is a test driver file for the Point class...
could you implement this function please, im having issues with it. void makeList (const ListNode::value_type [],const...
could you implement this function please, im having issues with it. void makeList (const ListNode::value_type [],const size_t& count) class ListNode { public: typedef int value_type; ListNode (value_type d = value_type(), ListNode* n = NULL) { datum = d; next = n; }    //Assessor value_type getDatum () const { return datum; } ListNode const* getNext () const { return next; }    //Mutator void setDatum (const value_type& d) {datum = d; } ListNode* getNext () { return next; } void...
Write the implementation of a non-member function Node* deleteSecond(Node* head_ptr), where Node is a class defined...
Write the implementation of a non-member function Node* deleteSecond(Node* head_ptr), where Node is a class defined on page 257. The function takes as input a pointer to the head of a linked list consisting of numbers. The function should remove the second item in the list. If the list had only one item, the function should delete that item. If the list was empty, then let the list remain empty. In all cases return the new head of the list...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT