I am writing a program for an assignment, i have a main that calls a test and the test simply tests all the functions within a class called int11, the int11 class and implementation are as follows
#ifndef INT11_H
#define INT11_H
#include "proj1.h"
class Int11 {
private:
T _left; // left endpoint
T _right; // right endpoint. left <= right
void setBoth(T left, T right); // ensure that left <= right
public:
// c-tors
Int11(T left, T right);
Int11(T val);
Int11();
// output
string toString () const; // ww standard name. use one of below, preferably toString0
string toString0() const; // standard interval notation: [a, b].
string toString1() const; // center/radius notation: c + rW.
// big three not needed
// methods:
// getters
T getLeft() const;
T getRight() const;
T getCenter() const;
T getRadius() const;
// no setters
// operators
// equality
bool operator != (const Int11 & rhs) const;
bool operator == (const Int11 & rhs) const;
private:
static const string _author;
static const string _affiliation;
static const string _course;
static const string _term;
static const string _project;
public:
static string getAuthor();
static string getAffiliation();
static string getCourse();
static string getTerm();
static string getProject();
};
ostream & operator << (ostream & os, const Int11 & rhs); // use toString
#endif // Int11_H
#include "int11.h"
#include <sstream>
//const string _author ("My Name");
//const string _affiliation ("Ohio University");
//const string _course ("CS240B");
//const string _term ("Fall 2011");
//const string _Project ("Assignment 1");
Int11::Int11(T left, T right){
if(left > right){
_left = (left + right)/2;
_right = (left + right)/2;
}
else{
_left = left;
_right = right;
}
}
Int11::Int11(T val){
_left = val;
_right = val;
}
Int11::Int11(){
_left = 0.0;
_right = 0.0;
}
void Int11::setBoth(T left, T right){
if(left <= right){
_left = left;
_right = right;
}
else{
_left = _right = (left + right) / 2;
}
}
T Int11::getLeft(){
return (_left);
}
T Int11::getRight(){
return (_right);
}
T Int11::getCenter(){
return ((_left + _right)/2);
}
T Int11::getRadius(){
return (((_left + _right)/2) - _left);
}
bool Int11::operator != (const Int11 & rhs) const{
if(*this.__left != rhs._left && *this.__right != rhs._right){
return true;
}
}
bool Int11::operator != (const Int11 & rhs) const{
return !(*this != rhs);
}
string Int11::toString() const{
return toString0();
}
string Int11::toString1() const{
ostringstream ss;
ss << getCenter();
ss << " + ";
ss << getRadius();
ss << "W";
return (ss.str());
}
string Int11::toString0() const{
ostringstream ss;
ss << "[";
ss << getLeft();
ss << " , ";
ss << getRight();
ss << "]";
return (ss.str());
}
string Int11::getAuthor(){
return (_author);
}
string Int11::getAffiliation(){
return (_affiliation);
}
string Int11::getCourse(){
return (_course);
}
string Int11::getTerm(){
return(_term);
}
string Int11::getProject(){
return(_project);
}
ostream & operator << (ostream & os, const Int11 & rhs){
os << rhs.getString();
const string _author ("My Name");
const string _affiliation ("Ohio University");
const string _course ("CS240B");
const string _term ("Fall 2011");
const string _Project ("Assignment 1");
my problem is in the first constructor, it gives me the error that i showed above in the title. Also in one of the files included there is a typedef double T, so thats where the T comes from.
Thanks for any help