Im having some error trouble now with my main program.
specifcally:
16 F:\testlocation.cpp no matching function for call to `location::assign(double)'
17 F:\testlocation.cpp no matching function for call to `location::assign(double)'
32 F:\testlocation.cpp could not convert `(&y)->location::operator=(((const location&)((const location*)(&x))))' to `bool'
note:in order to cut down in amount of lines the next errors cover the respective section
38 F:\testlocation.cpp no match for 'operator<<' in 'std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(&std::cout)), ((const char*)"x row=")) << x.location::Row'
43 F:\testlocation.cpp no match for 'operator<<' in 'std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(&std::cout)), ((const char*)"x column=")) << x.location::Colm'
48 F:\testlocation.cpp no match for 'operator<<' in 'std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(&std::cout)), ((const char*)"x=")) << x.location::inc'
main code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#include <iostream>
#include "location.h"
int main()
{
location x,y(1),z(1,2);
std::cout<<"testing constructor"<<std::endl;
std::cout<<"x="<<x<<std::endl;
std::cout<<"y="<<y<<std::endl;
std::cout<<"z="<<z<<std::endl;
std::cout<<"testing assign function"<<std::endl;
x.assign(3.7);
y.assign(9.3);
std::cout<<"Enter a location for z (r,c)";
std::cin>>z;
std::cout<<"x="<<x<<std::endl;
std::cout<<"y="<<y<<std::endl;
std::cout<<"z="<<z<<std::endl;
std::cout<<"testing == function"<<std::endl;
if (x==y)
std::cout<<"these points are equal";
else
std::cout<<"these points are not equal";
std::cout<<"testing = function"<<std::endl;
if (y=x)
std::cout<<"these points are equal";
else
std::cout<<"these points are not equal";
std::cout<<"testing row function"<<std::endl;
std::cout<<"x row="<<x.Row;
std::cout<<"y row="<<y.Row;
std::cout<<"z row="<<z.Row;
std::cout<<"testing colm function"<<std::endl;
std::cout<<"x column="<<x.Colm;
std::cout<<"y column="<<y.Colm;
std::cout<<"z column="<<z.Colm;
std::cout<<"testing inc function"<<std::endl;
std::cout<<"x="<<x.inc;
std::cout<<"y="<<y.inc;
std::cout<<"z="<<z.inc;
return 0;
}
| |
implementation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
[#include "location.h"
location::location(int r,int c)
{
row=r;
colm=c;
}
void location::assign(int r,int c)
{
row=r;
colm=c;
}
location location::operator = (const location& y)
{
row = y.row;
colm = y.colm;
return y;
}
bool location::operator == (const location& z)const
{
return((row==z.row)&&(colm==z.colm));
}
int location::Row()
{
return row;
}
int location::Colm()
{
return colm;
}
int location::inc(int a, int b)
{
a=1;
b=2;
row=+a;
colm=+b;
}
std::istream &operator>>(std::istream &input , location &x)
{
char a;
input>>a
>>x.row
>>a
>>x.colm
>>a;
return input;
}
std::ostream &operator<<(std::ostream &output , location &x)
{
output<<'('
<<x.row
<<','
<<x.colm
<<')';
return output;
}
| |
header
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
class location
{
friend std::istream &operator>>(std::istream& , location&);
friend std::ostream &operator<<(std::ostream& , location&);
private:
int row;
int colm;
public:
location (int=0,int=0);
void assign(int, int);
location operator =(const location&);
bool operator ==(const location&)const;
int inc(int, int);
int Row();
int Colm();
};
#endif
| |
if anyone could help, id appreciate it.