So here is my header file:
#pragma once
#ifndef HYPERINT_H
#define HYPERINT_H
#include <iostream>
#include <vector>
class Hyperint
{
public:
Hyperint();
Hyperint(long a);
~Hyperint(void);
Hyperint & operator*= (const Hyperint & right);
std::vector<int> hyperintVector;
};
Hyperint operator* (const Hyperint & left, const Hyperint &right);
#endif
here is my cpp file:
#include "stdafx.h"
#include "Hyperint.h"
using namespace std;
Hyperint::Hyperint(long a)
{
//vector<int> hyperint;
int b = a;
while (b != 0){
int h = b % 10;
this->hyperintVector.push_back(h);
b = b / 10;
}
}
Hyperint::~Hyperint()
{
}
Hyperint operator*(const Hyperint & left, const Hyperint & right){
vector<int> leftVec = left.hyperintVector;
vector<int> rightVec = right.hyperintVector;
vector<int> resultVector;
Hyperint result;
int carry = 0;
int counter1 = 0;
for (vector<int>::const_iterator it = leftVec.begin(); it != leftVec.end(); ++it){
int counter2 = 0;
int totalOperand = 0;
for (vector<int>::const_iterator it2 = rightVec.begin(); it2 != rightVec.end(); ++it2){
double pow2 = pow(10, counter2);
totalOperand += ((*it2) * ((int) pow2)) * (*it);
++counter2;
}
totalOperand += carry;
int store = totalOperand % 10;
resultVector.push_back(store);
carry = totalOperand / 10;
++counter1;
}
while (carry != 0){
int putIn = carry % 10;
resultVector.push_back(putIn);
carry /= 10;
}
result.hyperintVector = resultVector;
return result;
}
Hyperint & Hyperint::operator*=(const Hyperint & right){
vector<int> rightVec = right.hyperintVector;
//vector<int> leftVec = this->hyperintVector;
vector<int> resultVector;
Hyperint theResult;
int carry = 0;
int counter1 = 0;
for (vector<int>::const_iterator it = (this->hyperintVector).begin(); it != (this->hyperintVector).end(); ++it){
int counter2 = 0;
int totalOperand = 0;
for (vector<int>::const_iterator it2 = rightVec.begin(); it2 != rightVec.end(); ++it2){
double pow2 = pow(10, counter2);
totalOperand += ((*it2) *((int)pow2)) * (*it);
++counter2;
}
totalOperand += carry;
int store = totalOperand % 10;
resultVector.push_back(store);
carry = totalOperand / 10;
++counter1;
}
while (carry != 0){
int putIn = carry % 10;
resultVector.push_back(putIn);
carry = carry/10;
}
(this->hyperintVector) = resultVector;
return *this;
}
Now the problem arises when I compile it... I get 1 error and I don't know what it is, what it means, or why and how to fix it.
Error 1 error LNK2019: unresolved external symbol "public: __thiscall Hyperint::Hyperint(void)" (??0Hyperint@@QAE@XZ) referenced in function "public: class Hyperint & __thiscall Hyperint::operator*=(class Hyperint const &)" (??XHyperint@@QAEAAV0@ABV0@@Z) C:\Users\Drock\documents\visual studio 2013\Projects\A3-Attempt\A3-Attempt\Hyperint.obj A3-Attempt
Hyperint()constructor in your .cpp file. Seemingly you have only declared it in the header.