fork(1) download
  1. #include <iostream>
  2. #define STEK_SIZE 512
  3. using namespace std;
  4.  
  5.  
  6.  
  7.  
  8. template <typename uniVar>
  9. class stek{
  10. private:
  11. uniVar st[STEK_SIZE];
  12. int pos;
  13. public:
  14. bool operator << (uniVar &val){
  15. if(pos+1 < STEK_SIZE){
  16. st[++pos] = val;
  17. return true;
  18. }else{
  19. return false;
  20. }
  21. }
  22.  
  23. bool operator >> (uniVar &val){
  24. if(pos > -1){
  25. val = st[pos--];
  26. return true;
  27. }else{
  28. return false;
  29. }
  30. }
  31. friend bool operator << <>(uniVar &val, stek &ob);
  32. friend bool operator >> <>(uniVar &val, stek &ob);
  33. stek(){
  34. pos = -1;
  35. }
  36. };
  37.  
  38. template <typename uniVar>
  39. bool operator >> (uniVar &val, stek &ob){
  40. if(ob.pos+1 < STEK_SIZE){
  41. ob.st[++ob.pos] = val;
  42. return true;
  43. }else{
  44. return false;
  45. }
  46. }
  47.  
  48. template <typename uniVar>
  49. bool operator << (uniVar &val, stek &ob){
  50. if(ob.pos > -1){
  51. val = ob.st[ob.pos--];
  52. return true;
  53. }else{
  54. return false;
  55. }
  56. }
  57.  
  58.  
  59. int main(){
  60. char sym;
  61. char buffer[] = "hello world";
  62. stek<char> Stek;
  63.  
  64. Stek << buffer[10];
  65. Stek << buffer[9];
  66. Stek << buffer[8];
  67. Stek << buffer[7];
  68. Stek << buffer[6];
  69. Stek << buffer[5];
  70. Stek << buffer[4];
  71. Stek << buffer[3];
  72. Stek << buffer[2];
  73. buffer[1] >> Stek;
  74. buffer[0] >> Stek;
  75. while(Stek >> sym){
  76. cout << sym;
  77. }
  78. cout << endl;
  79. cout << "C++ work" << endl;
  80. return 0;
  81. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:31:30: error: declaration of ‘operator<<’ as non-function
         friend bool operator << <>(uniVar &val, stek &ob);
                              ^~
prog.cpp:31:30: error: expected ‘;’ at end of member declaration
prog.cpp:31:33: error: expected unqualified-id before ‘<’ token
         friend bool operator << <>(uniVar &val, stek &ob);
                                 ^
prog.cpp:32:30: error: declaration of ‘operator>>’ as non-function
         friend bool operator >> <>(uniVar &val, stek &ob);
                              ^~
prog.cpp:32:30: error: expected ‘;’ at end of member declaration
prog.cpp:32:33: error: expected unqualified-id before ‘<’ token
         friend bool operator >> <>(uniVar &val, stek &ob);
                                 ^
prog.cpp:39:36: error: ‘stek’ is not a type
     bool operator >> (uniVar &val, stek &ob){
                                    ^~~~
prog.cpp: In function ‘bool operator>>(uniVar&, int&)’:
prog.cpp:40:19: error: request for member ‘pos’ in ‘ob’, which is of non-class type ‘int’
             if(ob.pos+1 < STEK_SIZE){
                   ^~~
prog.cpp:41:20: error: request for member ‘st’ in ‘ob’, which is of non-class type ‘int’
                 ob.st[++ob.pos] = val;
                    ^~
prog.cpp:41:28: error: request for member ‘pos’ in ‘ob’, which is of non-class type ‘int’
                 ob.st[++ob.pos] = val;
                            ^~~
prog.cpp: At global scope:
prog.cpp:49:36: error: ‘stek’ is not a type
     bool operator << (uniVar &val, stek &ob){
                                    ^~~~
prog.cpp: In function ‘bool operator<<(uniVar&, int&)’:
prog.cpp:50:19: error: request for member ‘pos’ in ‘ob’, which is of non-class type ‘int’
             if(ob.pos > -1){
                   ^~~
prog.cpp:51:26: error: request for member ‘st’ in ‘ob’, which is of non-class type ‘int’
                 val = ob.st[ob.pos--];
                          ^~
prog.cpp:51:32: error: request for member ‘pos’ in ‘ob’, which is of non-class type ‘int’
                 val = ob.st[ob.pos--];
                                ^~~
prog.cpp: In function ‘int main()’:
prog.cpp:73:19: error: no match for ‘operator>>’ (operand types are ‘char’ and ‘stek<char>’)
         buffer[1] >> Stek;
         ~~~~~~~~~~^~~~~~~
prog.cpp:39:10: note: candidate: template<class uniVar> bool operator>>(uniVar&, int&)
     bool operator >> (uniVar &val, stek &ob){
          ^~~~~~~~
prog.cpp:39:10: note:   template argument deduction/substitution failed:
prog.cpp:73:22: note:   cannot convert ‘Stek’ (type ‘stek<char>’) to type ‘int&’
         buffer[1] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/iostream:40:0,
                 from prog.cpp:1:
/usr/include/c++/6/istream:924:5: note: candidate: template<class _CharT, class _Traits, class _Tp> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&)
     operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
     ^~~~~~~~
/usr/include/c++/6/istream:924:5: note:   template argument deduction/substitution failed:
prog.cpp:73:22: note:   mismatched types ‘std::basic_istream<_CharT, _Traits>’ and ‘char’
         buffer[1] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/iostream:40:0,
                 from prog.cpp:1:
/usr/include/c++/6/istream:808:5: note: candidate: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char*)
     operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
     ^~~~~~~~
/usr/include/c++/6/istream:808:5: note:   template argument deduction/substitution failed:
prog.cpp:73:22: note:   mismatched types ‘std::basic_istream<char, _Traits>’ and ‘char’
         buffer[1] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/iostream:40:0,
                 from prog.cpp:1:
/usr/include/c++/6/istream:803:5: note: candidate: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char*)
     operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
     ^~~~~~~~
/usr/include/c++/6/istream:803:5: note:   template argument deduction/substitution failed:
prog.cpp:73:22: note:   mismatched types ‘std::basic_istream<char, _Traits>’ and ‘char’
         buffer[1] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/iostream:40:0,
                 from prog.cpp:1:
/usr/include/c++/6/istream:761:5: note: candidate: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char&)
     operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
     ^~~~~~~~
/usr/include/c++/6/istream:761:5: note:   template argument deduction/substitution failed:
prog.cpp:73:22: note:   mismatched types ‘std::basic_istream<char, _Traits>’ and ‘char’
         buffer[1] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/iostream:40:0,
                 from prog.cpp:1:
/usr/include/c++/6/istream:756:5: note: candidate: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char&)
     operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
     ^~~~~~~~
/usr/include/c++/6/istream:756:5: note:   template argument deduction/substitution failed:
prog.cpp:73:22: note:   mismatched types ‘std::basic_istream<char, _Traits>’ and ‘char’
         buffer[1] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/istream:934:0,
                 from /usr/include/c++/6/iostream:40,
                 from prog.cpp:1:
/usr/include/c++/6/bits/istream.tcc:923:5: note: candidate: template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT&)
     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
     ^~~~~~~~
/usr/include/c++/6/bits/istream.tcc:923:5: note:   template argument deduction/substitution failed:
prog.cpp:73:22: note:   mismatched types ‘std::basic_istream<_CharT, _Traits>’ and ‘char’
         buffer[1] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/istream:934:0,
                 from /usr/include/c++/6/iostream:40,
                 from prog.cpp:1:
/usr/include/c++/6/bits/istream.tcc:955:5: note: candidate: template<class _CharT2, class _Traits2> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT2*)
     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
     ^~~~~~~~
/usr/include/c++/6/bits/istream.tcc:955:5: note:   template argument deduction/substitution failed:
prog.cpp:73:22: note:   mismatched types ‘std::basic_istream<_CharT, _Traits>’ and ‘char’
         buffer[1] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/string:53:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/basic_string.tcc:1437:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)
     operator>>(basic_istream<_CharT, _Traits>& __in,
     ^~~~~~~~
/usr/include/c++/6/bits/basic_string.tcc:1437:5: note:   template argument deduction/substitution failed:
prog.cpp:73:22: note:   mismatched types ‘std::basic_istream<_CharT, _Traits>’ and ‘char’
         buffer[1] >> Stek;
                      ^~~~
prog.cpp:74:19: error: no match for ‘operator>>’ (operand types are ‘char’ and ‘stek<char>’)
         buffer[0] >> Stek;
         ~~~~~~~~~~^~~~~~~
prog.cpp:39:10: note: candidate: template<class uniVar> bool operator>>(uniVar&, int&)
     bool operator >> (uniVar &val, stek &ob){
          ^~~~~~~~
prog.cpp:39:10: note:   template argument deduction/substitution failed:
prog.cpp:74:22: note:   cannot convert ‘Stek’ (type ‘stek<char>’) to type ‘int&’
         buffer[0] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/iostream:40:0,
                 from prog.cpp:1:
/usr/include/c++/6/istream:924:5: note: candidate: template<class _CharT, class _Traits, class _Tp> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&)
     operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
     ^~~~~~~~
/usr/include/c++/6/istream:924:5: note:   template argument deduction/substitution failed:
prog.cpp:74:22: note:   mismatched types ‘std::basic_istream<_CharT, _Traits>’ and ‘char’
         buffer[0] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/iostream:40:0,
                 from prog.cpp:1:
/usr/include/c++/6/istream:808:5: note: candidate: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char*)
     operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
     ^~~~~~~~
/usr/include/c++/6/istream:808:5: note:   template argument deduction/substitution failed:
prog.cpp:74:22: note:   mismatched types ‘std::basic_istream<char, _Traits>’ and ‘char’
         buffer[0] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/iostream:40:0,
                 from prog.cpp:1:
/usr/include/c++/6/istream:803:5: note: candidate: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char*)
     operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
     ^~~~~~~~
/usr/include/c++/6/istream:803:5: note:   template argument deduction/substitution failed:
prog.cpp:74:22: note:   mismatched types ‘std::basic_istream<char, _Traits>’ and ‘char’
         buffer[0] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/iostream:40:0,
                 from prog.cpp:1:
/usr/include/c++/6/istream:761:5: note: candidate: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char&)
     operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
     ^~~~~~~~
/usr/include/c++/6/istream:761:5: note:   template argument deduction/substitution failed:
prog.cpp:74:22: note:   mismatched types ‘std::basic_istream<char, _Traits>’ and ‘char’
         buffer[0] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/iostream:40:0,
                 from prog.cpp:1:
/usr/include/c++/6/istream:756:5: note: candidate: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char&)
     operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
     ^~~~~~~~
/usr/include/c++/6/istream:756:5: note:   template argument deduction/substitution failed:
prog.cpp:74:22: note:   mismatched types ‘std::basic_istream<char, _Traits>’ and ‘char’
         buffer[0] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/istream:934:0,
                 from /usr/include/c++/6/iostream:40,
                 from prog.cpp:1:
/usr/include/c++/6/bits/istream.tcc:923:5: note: candidate: template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT&)
     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
     ^~~~~~~~
/usr/include/c++/6/bits/istream.tcc:923:5: note:   template argument deduction/substitution failed:
prog.cpp:74:22: note:   mismatched types ‘std::basic_istream<_CharT, _Traits>’ and ‘char’
         buffer[0] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/istream:934:0,
                 from /usr/include/c++/6/iostream:40,
                 from prog.cpp:1:
/usr/include/c++/6/bits/istream.tcc:955:5: note: candidate: template<class _CharT2, class _Traits2> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT2*)
     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
     ^~~~~~~~
/usr/include/c++/6/bits/istream.tcc:955:5: note:   template argument deduction/substitution failed:
prog.cpp:74:22: note:   mismatched types ‘std::basic_istream<_CharT, _Traits>’ and ‘char’
         buffer[0] >> Stek;
                      ^~~~
In file included from /usr/include/c++/6/string:53:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/basic_string.tcc:1437:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)
     operator>>(basic_istream<_CharT, _Traits>& __in,
     ^~~~~~~~
/usr/include/c++/6/bits/basic_string.tcc:1437:5: note:   template argument deduction/substitution failed:
prog.cpp:74:22: note:   mismatched types ‘std::basic_istream<_CharT, _Traits>’ and ‘char’
         buffer[0] >> Stek;
                      ^~~~
stdout
Standard output is empty