Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8640817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:22:17+00:00 2026-06-12T11:22:17+00:00

Possible Duplicate: What is an undefined reference/unresolved external symbol error and how do I

  • 0

Possible Duplicate:
What is an undefined reference/unresolved external symbol error and how do I fix it?

I keep getting

error LNK2019: unresolved external symbol “public: void __thiscall DynamicArray::put(double)” (?put@?$DynamicArray@N@@QAEXN@Z) referenced in function _main.

The only time I get this error is when I call the “put” function from the DynamicArray class

DynamicArray.h

#ifndef DYNAMICARRAY_H
#define DYNAMICARRAY_H
#include <new>
#include <cstdlib>
using namespace std;

template <class T>
class DynamicArray
{
    private:
        T *origin;
        T *allocator;
        int size;
        int current;


    public:
        DynamicArray();
        DynamicArray(int);
        DynamicArray(const DynamicArray&);
       ~DynamicArray();
        void add(int);
        void erase(int);
        void empty();
        void put(T);
        void remove();
        int getSize();
        T &operator[](const int&);
        const T operator=(const DynamicArray&);
        void put(T&);
};
template <class T>
DynamicArray<T>::DynamicArray()
{
    origin = new T[5];
    allocator = NULL;
    size = 5;
    current = 0;
}

template <class T>
DynamicArray<T>::DynamicArray(int s)
{
    size = s;

    try
    {
        origin = new T[s];
        allocator = NULL;
    }
    catch(bad_alloc)
    {
        cout << "Error: Bad memery allocation\n";
        exit(EXIT_FAILURE);
    }
}

template <class T>
DynamicArray<T>::DynamicArray(const DynamicArray& obj)
{
    empty();
    for(int counter = 0; counter < obj.size - 1; counter++)
    {
         origin[counter] = obj.origin[counter];
    }
}

template <class T>
DynamicArray<T>::~DynamicArray()
{
    delete [] origin;
    delete [] allocator;
    size = NULL;
}

template <class T>
void DynamicArray<T>::add(int size)
{
    allocator = new T[size];
    for(int counter = 0; counter < this-> size - 1; counter++)
    {
        allocator[counter] = origin[counter];
    }
    origin = NULL;
    origin = new T[size];
    this->size = this->size + size;

    for(int counter = 0; counter < size - 1; counter++)
    {
         origin[counter] = allocator[counter];
    }
    allocator = NULL;
}

template <class T>
void DynamicArray<T>::erase(int ammount)
{
    if(ammount - size > size)
        throw "\nnegetive memory location error\n";

    allocator = new T[size - ammount];

    for(int counter = 0; counter < this-> size - ammount - 1; counter++)
    {
        allocator[counter] = origin[counter];
    }

    origin = NULL;
    size = size - ammount;
    origin = new T[size];

    for(int counter = 0; counter < size - 1; counter++)
    {
        origin[counter] = allocator[counter];
    }
    allocator = NULL;
}

template <class T>
void DynamicArray<T>::empty()
{
    if(size >= 0)
        delete [] origin;
}


template <class T>
void DynamicArray<T>::remove()
{
     erase(1);
}


template <class T>
int DynamicArray<T>::getSize()
{
     return size;
}

template <class T>
T &DynamicArray<T>::operator[](const int &index)
{
    return origin[index];
}


template <class T>
const T DynamicArray<T>::operator=(const DynamicArray &obj)
{
    size = obj.size;
    delete [] origin;

    origin = new T[size];

    for(int counter = 0; counter < size; counter++)
        *(origin + counter) = *(obj.origin + counter);

    return *origin;
}

template <class T>
void DynamicArray<T>::put(T &obj)
{
    if(current == size - 1)
    {

        add(1);
        origin[size - 1] = obj;
        ++current; 
    }
    else
    {
        origin[current] = obj;
        ++current;
    }
}

#endif // !DYNAMICARRAY_H

main.cpp

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

using namespace std;

int main()
{
    DynamicArray<double> a(5);

    a.put(1);

    system("pause");
    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:22:18+00:00Added an answer on June 12, 2026 at 11:22 am

    Your header file says void put(T); but no such function was ever defined. (There is a similar one void put(T&); but close doesn’t count to the linker.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: What is an undefined reference/unresolved external symbol error and how do I
Possible Duplicate: What is an undefined reference/unresolved external symbol error and how do I
Possible Duplicate: What is an undefined reference/unresolved external symbol error and how do I
Possible Duplicate: What is an undefined reference/unresolved external symbol error and how do I
Possible Duplicate: Undefined reference - C++ linker error Now, I'm getting an Undefined reference
Possible Duplicate: Why do I get “unresolved external symbol” errors when using templates? “undefined
Possible Duplicate: sem_open() error: “undefined reference to sem_open()” on linux (Ubuntu 10.10) Having issues
Possible Duplicate: Why do I get “unresolved external symbol” errors when using templates? Why
Possible Duplicate: What does it mean to have an undefined reference to a static
Possible Duplicate: Undefined Symbol ___gxx_personality_v0 on link I have a problem with the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.