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

  • Home
  • SEARCH
  • 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 6142751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:25:55+00:00 2026-05-23T18:25:55+00:00

I already read like 15 of the undefined reference topics here and used google

  • 0

I already read like 15 of the undefined reference topics here and used google too to find a valid answer, but there was non that really helped.

I wrote a 1D and 2D simple storage class which allows rapid loop through by directly accessing the data (plus some convenience accessors). Here the 1D goes (2D is pretty much the same, just 2D)

Header:

#ifndef MULTI1_H
#define MULTI1_H
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

template <class T>
class Multi1
{
public:
    Multi1(int32_t size_ = -1);
    ~Multi1();
    void set(T val, int32_t pos);
    T& operator[] (int32_t pos) const;
    T& at(int32_t pos) const;
    int32_t m_size;
    T *m_data;
};

#endif // MULTI1_H

Body:

#include "multi1.h"

template <class T>
Multi1<T>::Multi1(int32_t size_) :
  m_size(size_),
  m_data(NULL)
{
  if (size_>0)
    m_data = (T *) malloc (sizeof(T)*size_);
  else
     m_size = 0;
}

template <class T>
Multi1<T>::~Multi1()
{
  if (m_data!=NULL)
    free (m_data);
}

template <class T>
void Multi1<T>::set(T val, int32_t pos)
{
  m_data[pos] = val;
}

template <class T>
T& Multi1<T>::operator[](int32_t pos) const
{
  return m_data[pos];
}

template <class T>
T& Multi1<T>::at(int32_t pos) const
{
  return m_data[pos];
}


./build/main.o: In function `setupDemo(Multi1<voCam*>&, Multi1<voBoard*>&, Multi2<voBoardObservation*>&)':
./src/main.cpp:32: undefined reference to `Multi1<voCam*>::operator[](int) const'
./src/main.cpp:31: undefined reference to `Multi1<voCam*>::operator[](int) const'
./src/main.cpp:30: undefined reference to `Multi1<voBoard*>::operator[](int) const'
./src/main.cpp:29: undefined reference to `Multi1<voBoard*>::operator[](int) const'
./src/main.cpp:41: undefined reference to `Multi1<voCam*>::operator[](int) const'
....

I checked the includes like 5 times, and I recently got pretty used to C programming where I can keep things like linker vendetta from my neck.

Note: I am compiling with g++, linker flags are -lstdc++ -lm

  • 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-05-23T18:25:55+00:00Added an answer on May 23, 2026 at 6:25 pm

    Where have you defined?

    Multi1<voCam*>::operator[](int) const
    

    Ah ok, You have it, You should have template declaration and definition in the same header file.

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

Sidebar

Related Questions

I already read the datasheet and google but I still don't understand something. In
I have already read all the previous similar posts but I couldn't find a
I've already read some articles about this matter, but I'd like to ask once
i've already read all tha articles in here wich touch a similar problem but
I know this post , I've already read it but still I'd like to
I already read many article about this issue in here, SO. I just want
I already read these methods as alternative for unsafeWindow. But I still can't get
From what I've already read this appears to be impossible, but I wanted to
I've already read this question and this question and this , but none of
I've already read through the similar questions on this topic, but none of them

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.