0

I've started to "port" my Java implementation of dynamic array to C++ and somehow i'm facing a strange linker error (LNK2019 and LNK2011) in my code, although i don't see any place which can produce such error. I think it has something to do with constructor, but i can't find what exactly. Thank you for your help!

DynStackArrayQueue.cpp (test class) :

#include <iostream>
#include "DynArray.h"

using namespace std;

int main()
{
    DynArray dynA (3, 6);
}

DynArray.h

#pragma once

class DynArray {
private:
    int growthFactor, maxOverhead;
    int elements[];
public:
    DynArray(int growthFactor, int maxOverhead);
}

DynArray.cpp

#include <iostream>
#include "DynArray.h"

using namespace std;

DynArray::DynArray(int growthFactor, int maxOverhead) {
       this->growthFactor = growthFactor;
       this->maxOverhead = maxOverhead;
    }

The error itself:

LNK-Error

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97

1 Answers1

0

You have missed a semicolon at the end of the class declaration. This leads to a compilation error, which you actually should be able to see before the linker error. Solution: add a semicolon after the closing brace of your DynArray class definition.

Benjamin Bihler
  • 1,612
  • 11
  • 32