VLI.h:
#include <string>
#include <vector>
class VLI
{
public:
VLI();
VLI(const std::string &);
VLI operator +(const VLI & num);
private:
std::vector<unsigned int> digits;
};
VLI.cpp:
#include "VLI.h"
#include <vector>
#include <iostream>
#include <string>
#define UNIT_NUM 9
VLI::VLI()
{
this->digits.push_back(0);
}
VLI::VLI(const std::string &form)
{
std::string::const_iterator stop = form.begin();
std::string::const_iterator start = form.end() - 1;
for(unsigned int val = 0; start >= stop ; start--)
{
val = *start - '0';
digits.push_back(val);
}
}
VLI::VLI operator +(const VLI &num)
{
VLI temp_VLI;
for(size_t i = next = temp = 0, siz = num.size() ; i < siz ; ++i)
{
temp = num.digits[i] + this->digits[i] + next;
next = 0;
if(temp > UNIT_NUM)
{
next = 1;
temp %= (UNIT_NUM + 1);
}
temp_VLI.digits[i]push_back(temp);
}
return temp_VLI;
}
Kompilator mówi:
'VLI::VLI' names the constructor, not the type
Jak zadeklarotwac ten operator by nie myslal ze to konstruktor?
dodanie znacznika <quote> dla treści błędu - fp