00001 // #include "ctest.h" 00002 // 00003 // test::test(){ 00004 // std::cerr << "test init\n" ; 00005 // mint = 10 ; 00006 // } 00007 // 00008 // test::~test(){ 00009 // } 00010 // 00011 // int test::getpriv(){ 00012 // return mint ; 00013 // } 00014 // 00015 // Atest::Atest(){ 00016 // std::cerr << "Atest init\n" ; 00017 // mint = 20 ; 00018 // } 00019 // Atest::~Atest(){ 00020 // } 00021 // 00022 // int Atest::getpriv(){ 00023 // return mint ; 00024 // } 00025 00026 00027 // //friend to ostream 00028 // ctest& operator<<(std::ostream &os,const ctest &obj){ 00029 // os << "cerr: " << obj.m_name << std::endl ; 00030 // } 00031 // 00032 // void ctest::operator=(int obj){ 00033 // this->m_int = obj; 00034 // std::cerr << this->m_name << " operator l-value assumes: " << obj << std::endl ; 00035 // } 00036 // 00037 // ctest& ctest::operator<<(ctest &obj){ 00038 // std::cerr << this->m_name << " operator get: " << obj.m_name << std::endl ; 00039 // this->m_name += " " + obj.m_name ; 00040 // } 00041 00042 00043 00044 00045 /* 00046 //CODE TO GET A SINGLE CHAR VIA UNBUFFERED CONSOLE 00047 #include <termios.h> 00048 #include <iostream> 00049 #include <iomanip> 00050 00051 using namespace std; 00052 00053 int main(){ 00054 termios before, after; 00055 tcgetattr (STDIN_FILENO, &before); // fill 'before' with current termios values 00056 after = before; // make a copy to be modified 00057 after.c_lflag &= (~ICANON); // Disable canonical mode, including line buffering 00058 after.c_lflag &= (~ECHO); // Don't echo characters on the screen (optional) 00059 tcsetattr (STDIN_FILENO, TCSANOW, &after); // Set the modified flags 00060 char ch; 00061 cerr << "Hit Escape to quit.\n"; 00062 do 00063 { 00064 cin.get(ch); 00065 cerr << "ch = " << setw(3) << (int) ch; 00066 if (isprint(ch)) 00067 cerr << " '" << ch << "'"; 00068 cerr << endl; 00069 } 00070 while((int) ch != 27); 00071 tcsetattr (STDIN_FILENO, TCSANOW, &before); 00072 return 0; 00073 } 00074 */ 00075