G
Gary Wessle
Hi
I tried so long, so many ways to find out why this code is not
compiling, I appreciate any help with it,
thank you
****************************************************************
#include <iomanip>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <utility> // std:air
#include <map>
using namespace std;
class T {
double _bef, _aft;
public:
T(double b, double a):
_bef(b),
_aft(a)
{}
double bef() const {return _bef;}
double aft() const {return _aft;}
};
class P{
protected:
char _fir[40];
char _sec[40];
char _all[80];
public:
P( const char* all)
{
strncpy(_fir, all, 3);
_fir[3]='\0';
strncpy(_sec, all+4, 3);
_sec[3]='\0';
strncpy(_all, all, 3);
_all[3]='\0';
strcat(_all, _sec);
}
char* fir() { return _fir;}
char* sec() { return _sec;}
char* all() { return _all;}
};
class Info{
int x;
public:
Info()/* bunch of stuff here */ {}
std::map<P,T> t4p;
std::vector<P> vp;
};
class RT {
std::vector<double> vi;
double a, b;
public:
RT();
T getRt(const P& p){
T k(a,b);
return k;
}
};
class Spac_task{
public:
Info info;
void c_d(){
for ( vector<P>::iterator b=info.vp.begin(); b!=info.vp.end(); ++b){
T tmp = info.RT.getrt( *b );
pair<P,T> f(*b, tmp);
info.t4p.insert(f); //<<<<<<<<<<<<<<<< error line
}
}
};
int main(){
Info i;
Spac_task st;
}
****************************************************************
cd /home/fred/myProg/toy/
make -k
g++ -gdwarf-2 -c -o main.o main.cpp
main.cpp: In member function ‘void Spac_task::c_d()’:
main.cpp:69: error: ‘class Info’ has no member named ‘RT’
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_function.h: In member function ‘bool std::less<_Tp>:perator()(const _Tp&, const _Tp&) const [with _Tp = P]’:
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_tree.h:921: instantiated from ‘std:air<typename std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::insert_unique(const _Val&) [with _Key = P, _Val = std:air<const P, T>, _KeyOfValue = std::_Select1st<std:air<const P, T> >, _Compare = std::less<P>, _Alloc = std::allocator<std:air<const P, T> >]’
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_map.h:396: instantiated from ‘std:air<typename std::_Rb_tree<_Key, std:air<const _Key, _Tp>, std::_Select1st<std:air<const _Key, _Tp> >, _Compare, typename _Alloc::rebind<std:air<const _Key, _Tp> >:ther>::iterator, bool> std::map<_Key, _Tp, _Compare, _Alloc>::insert(const std:air<const _Key, _Tp>&) [with _Key = P, _Tp = T, _Compare = std::less<P>, _Alloc = std::allocator<std:air<const P, T> >]’
main.cpp:71: instantiated from here
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_function.h:227: error: no match for ‘operator<’ in ‘__x < __y’
make: *** [main.o] Error 1
make: Target `proj' not remade because of errors.
Compilation exited abnormally with code 2 at Tue Nov 21 15:18:04
I tried so long, so many ways to find out why this code is not
compiling, I appreciate any help with it,
thank you
****************************************************************
#include <iomanip>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <utility> // std:air
#include <map>
using namespace std;
class T {
double _bef, _aft;
public:
T(double b, double a):
_bef(b),
_aft(a)
{}
double bef() const {return _bef;}
double aft() const {return _aft;}
};
class P{
protected:
char _fir[40];
char _sec[40];
char _all[80];
public:
P( const char* all)
{
strncpy(_fir, all, 3);
_fir[3]='\0';
strncpy(_sec, all+4, 3);
_sec[3]='\0';
strncpy(_all, all, 3);
_all[3]='\0';
strcat(_all, _sec);
}
char* fir() { return _fir;}
char* sec() { return _sec;}
char* all() { return _all;}
};
class Info{
int x;
public:
Info()/* bunch of stuff here */ {}
std::map<P,T> t4p;
std::vector<P> vp;
};
class RT {
std::vector<double> vi;
double a, b;
public:
RT();
T getRt(const P& p){
T k(a,b);
return k;
}
};
class Spac_task{
public:
Info info;
void c_d(){
for ( vector<P>::iterator b=info.vp.begin(); b!=info.vp.end(); ++b){
T tmp = info.RT.getrt( *b );
pair<P,T> f(*b, tmp);
info.t4p.insert(f); //<<<<<<<<<<<<<<<< error line
}
}
};
int main(){
Info i;
Spac_task st;
}
****************************************************************
cd /home/fred/myProg/toy/
make -k
g++ -gdwarf-2 -c -o main.o main.cpp
main.cpp: In member function ‘void Spac_task::c_d()’:
main.cpp:69: error: ‘class Info’ has no member named ‘RT’
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_function.h: In member function ‘bool std::less<_Tp>:perator()(const _Tp&, const _Tp&) const [with _Tp = P]’:
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_tree.h:921: instantiated from ‘std:air<typename std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::insert_unique(const _Val&) [with _Key = P, _Val = std:air<const P, T>, _KeyOfValue = std::_Select1st<std:air<const P, T> >, _Compare = std::less<P>, _Alloc = std::allocator<std:air<const P, T> >]’
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_map.h:396: instantiated from ‘std:air<typename std::_Rb_tree<_Key, std:air<const _Key, _Tp>, std::_Select1st<std:air<const _Key, _Tp> >, _Compare, typename _Alloc::rebind<std:air<const _Key, _Tp> >:ther>::iterator, bool> std::map<_Key, _Tp, _Compare, _Alloc>::insert(const std:air<const _Key, _Tp>&) [with _Key = P, _Tp = T, _Compare = std::less<P>, _Alloc = std::allocator<std:air<const P, T> >]’
main.cpp:71: instantiated from here
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_function.h:227: error: no match for ‘operator<’ in ‘__x < __y’
make: *** [main.o] Error 1
make: Target `proj' not remade because of errors.
Compilation exited abnormally with code 2 at Tue Nov 21 15:18:04