fork download
  1.  
  2. #include <cstdlib>
  3. #include <iostream>
  4. #include <vector>
  5. #include "OverLoad.h"
  6. #include <cmath>
  7.  
  8. using namespace std;
  9.  
  10. class Overload {
  11. public:
  12. Overload();
  13. Overload(int);
  14. Overload operator+(Overload &) ;
  15. void SetK(int k);
  16. int GetK() const;
  17. void SetVect(vector<double> vect);
  18. vector<double> GetVect() const;
  19.  
  20.  
  21. private:
  22. vector<double> vect ;
  23. int k ;
  24.  
  25.  
  26. };
  27.  
  28. int main(int argc, char** argv) {
  29.  
  30. Overload a,b(10),c(10) ;
  31. a = b+c ;
  32.  
  33. cout << a.GetVect() ;
  34. return 0;
  35. }
  36.  
  37.  
  38. Overload::Overload() {
  39. k=10 ;
  40. for(unsigned int i=0;i<k ; ++i){
  41. double res = 1/pow(i,2) ;
  42. vect.push_back(res);
  43. }
  44. }
  45.  
  46. Overload::Overload(int k) {
  47.  
  48. for(unsigned int i=0;i<k ; ++i){
  49. double res = 1/pow(i,2) ;
  50. vect.push_back(res);
  51. }
  52. }
  53.  
  54. Overload Overload::operator+(Overload &a){
  55.  
  56. Overload x ;
  57. for(unsigned int i=0 ;i<vect.size();i++) {
  58. double res = vect[i] + a.vect[i];
  59. x.vect.push_back(res) ;
  60. }
  61. return x ;
  62. }
  63.  
  64. void Overload::SetK(int k) {
  65. this->k = k;
  66. }
  67.  
  68. int Overload::GetK() const {
  69. return k;
  70. }
  71.  
  72. void Overload::SetVect(vector<double> vect) {
  73. this->vect = vect;
  74. }
  75.  
  76. vector<double> Overload::GetVect() const {
  77. return vect;
  78. }
  79.  
  80.  
  81.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:5:22: error: OverLoad.h: No such file or directory
prog.cpp: In function ‘int main(int, char**)’:
prog.cpp:33: error: no match for ‘operator<<’ in ‘std::cout << Overload::GetVect() const()’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ostream:112: note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>& (*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ostream:121: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ostream:131: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ostream:169: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ostream:173: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ostream:177: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/ostream.tcc:97: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ostream:184: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/ostream.tcc:111: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ostream:195: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ostream:204: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ostream:208: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ostream:213: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ostream:217: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ostream:225: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ostream:229: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/ostream.tcc:125: note:                 std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>]
prog.cpp: In constructor ‘Overload::Overload()’:
prog.cpp:40: warning: comparison between signed and unsigned integer expressions
prog.cpp: In constructor ‘Overload::Overload(int)’:
prog.cpp:48: warning: comparison between signed and unsigned integer expressions
stdout
Standard output is empty