#ifndef STRING1030_H
#define STRING1030_H
#include<iostream>
using std::ostream;
using std::istream;
using std::endl;
using std::cerr;
/*
* The class String1030 is for the students to practice implementing
* more class functions and making sure that their implementation
* is reasonable.
*
* It requires some skill in using arrays and overloading operators.
*
* Note that the sentinel value that MUST be part of the storage for our
* strings is '\0'. That is not special, it is just a way to tell future
* readers that we know what we are doing. We could just as well use the
* digit 0, but that can be confusing.
*/
/*
* If you do not understand any of this, come see me or the TA.
*/
class String1030
{
public:
// The constructor. The "0" is the digit 0 NOT a
// character. It is used to let us know that
// nothing is being passed to the constructor.
String1030(constchar *buf=0);
//This next is a "copy" constructor. Remember that
//we have to create new storage and then copy
//the array content. We must not just copy the pointer.
String1030(const String1030& oldstring);
// The destructor because we are allocating memory.
// We must deallocate it when the object goes out of
// scope (is destroyed).
~String1030();
String1030& operator=(const String1030& right);
// Allows to change the element at a certain index.
char& operator[](int index);
int getSize(void);
void setSize(int newsize);
constchar *getString();
// Replace the existing string with a new one.
void setString(constchar *carray);
private:
char *buffer;
int mysize;
};
#endif
Lines 14, 20, 42, all in the first file, on the top. I am using visual studios 2012
Also intellisense says for the same lines(14,20,42) IntelliSense: the object has type qualifiers that are not compatible with the member function
object type is: const String1030 \\wi\Desktop\Prog10\Prog10\String1030.cpp 41 6 Prog10
its because oldstring is declared as const and getSize is not.
line 55 of your header file int getSize(void); change to int getSize(void) const; and do the same in your .cpp file.
I know your not supposed to change the .h file but I don't see a way around it
[EDIT] actually you don't need to use the getSize function to access mysize. you can just use oldstring.mysize;
4 IntelliSense: expression preceding parentheses of apparent call must have (pointer-to-) function type
Error 1 error C2064: term does not evaluate to a function taking 0 arguments
is what i get when i changed the oldstring.getSize to oldstring.mysize. I am confused if your also telling me to remove the getSize below where it returns mysize?