P
PengYu.UT
I forward declared the class test. But I still get some error. Would
you please help me to find out what is wrong with this program?
Peng
//#include <utility>
#include <iostream>
//using namespace std::rel_ops;
class test;
class const_test{
public:
friend class test;
const_test(const test &t) : _i(t._i){}//error
const_test(int i) : _i(i){}
bool operator == (const const_test& t) const {
return _i == t._i;
}
private:
int _i;
};
class test{
public:
test(int i) : _i(i){}
bool operator == (const const_test& t) const {
return _i == t._i;
}
private:
int _i;
};
int main(){
test t1(1);
test t2(2);
// std::cout << (t1 != t2) << std::endl;
// std::cout << (t1 == t2) << std::endl;
}
you please help me to find out what is wrong with this program?
Peng
//#include <utility>
#include <iostream>
//using namespace std::rel_ops;
class test;
class const_test{
public:
friend class test;
const_test(const test &t) : _i(t._i){}//error
const_test(int i) : _i(i){}
bool operator == (const const_test& t) const {
return _i == t._i;
}
private:
int _i;
};
class test{
public:
test(int i) : _i(i){}
bool operator == (const const_test& t) const {
return _i == t._i;
}
private:
int _i;
};
int main(){
test t1(1);
test t2(2);
// std::cout << (t1 != t2) << std::endl;
// std::cout << (t1 == t2) << std::endl;
}