#include <cstdlib>
#include <iostream>
#include <vector>
#include "OverLoad.h"
#include <cmath>
using namespace std;
class Overload {
public:
Overload();
Overload(int);
Overload operator+(Overload &) ;
void SetK(int k);
int GetK() const;
void SetVect(vector<double> vect);
vector<double> GetVect() const;
private:
vector<double> vect ;
int k ;
};
int main(int argc, char** argv) {
Overload a,b(10),c(10) ;
a = b+c ;
cout << a.GetVect() ;
return 0;
}
Overload::Overload() {
k=10 ;
for(unsigned int i=0;i<k ; ++i){
double res = 1/pow(i,2) ;
vect.push_back(res);
}
}
Overload::Overload(int k) {
for(unsigned int i=0;i<k ; ++i){
double res = 1/pow(i,2) ;
vect.push_back(res);
}
}
Overload Overload::operator+(Overload &a){
Overload x ;
for(unsigned int i=0 ;i<vect.size();i++) {
double res = vect[i] + a.vect[i];
x.vect.push_back(res) ;
}
return x ;
}
void Overload::SetK(int k) {
this->k = k;
}
int Overload::GetK() const {
return k;
}
void Overload::SetVect(vector<double> vect) {
this->vect = vect;
}
vector<double> Overload::GetVect() const {
return vect;
}
CiNpbmNsdWRlIDxjc3RkbGliPgojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlICJPdmVyTG9hZC5oIgojaW5jbHVkZSA8Y21hdGg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgT3ZlcmxvYWQgewpwdWJsaWM6CiAgICBPdmVybG9hZCgpOwogICAgT3ZlcmxvYWQoaW50KTsKICAgIE92ZXJsb2FkIG9wZXJhdG9yKyhPdmVybG9hZCAmKSA7CiAgICB2b2lkIFNldEsoaW50IGspOwogICAgaW50IEdldEsoKSBjb25zdDsKICAgIHZvaWQgU2V0VmVjdCh2ZWN0b3I8ZG91YmxlPiB2ZWN0KTsKICAgIHZlY3Rvcjxkb3VibGU+IEdldFZlY3QoKSBjb25zdDsKICAgCiAgICAKcHJpdmF0ZToKICAgIHZlY3Rvcjxkb3VibGU+IHZlY3QgOwogICAgaW50IGsg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hZDo6R2V0VmVjdCgpIGNvbnN0IHsKICAgIHJldHVybiB2ZWN0Owp9CgoK
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