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 6246985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:47:14+00:00 2026-05-24T12:47:14+00:00

I’m using Android NDK r6 and Android SDK API 8 (2.2). I’m trying to

  • 0

I’m using Android NDK r6 and Android SDK API 8 (2.2).

I’m trying to implement a dynamic list like std::vector using templates but I get plenty of errors in the compiled .o files.

A sample:

error

As you can see the errors are produced in the compiled .o files, not in source files.

Class definition:

template <class T>
class ArrayList{
    private:
        int mSize;

    public:
        /**
         * Construye una lista dinámica vacía.
         */
        ArrayList ();

        /**
         * Destructor.
         */
        ~ArrayList ();

        /**
         * Añade un elemento a la lista.
         *
         * @param element
         *              Elemento.
         */
        void add (T element);

        /**
         * Obtiene un elemento de la lista.
         *
         * @param index
         *              Índice del elemento. Rango válido de valores: [0, size()]
         * @return Elemento de la posición indicada o NULL si el índice no es válido.
         */
        T get (int index);

        /**
         * Elimina un elemento de la lista.
         *
         * @param index
         *              Índice del elemento. Rango válido de valores: [0, size()]
         */
        void remove (int index);

        /**
         * Vacía la lista.
         */
        void clear ();

        /**
         * Consulta el número de elementos de la lista.
         *
         * @return Número de elementos.
         */
        int size ();

        /**
         * Consulta si la lista esta vacía.
         *
         * @return true si está vaía, sinó false.
         */
        bool isEmpty ();
};

Class implementation:

template <class T>
ArrayList<T>::ArrayList (){
    mSize = 0;
}

template <class T>
ArrayList<T>::~ArrayList (){

}

template <class T>
void ArrayList<T>::add (T element){

}

template <class T>
T ArrayList<T>::get (int index){
    T element;
    return element;
}

template <class T>
void ArrayList<T>::remove (int index){

}

template <class T>
void ArrayList<T>::clear (){

}

template <class T>
int ArrayList<T>::size (){
    return mSize;
}

template <class T>
bool ArrayList<T>::isEmpty (){
    return true;
}

Class usage:

ArrayList<OtherClass> list;
OtherClass foo;
list.add (foo);
  • 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-24T12:47:15+00:00Added an answer on May 24, 2026 at 12:47 pm

    It’s template code. You don’t have the same header file to cpp file relationship like a normal C++ class. I generally restructure it like so:

    Foo.h:

    #ifndef FOO_H
    #define FOO_H
    
    template <class T>
    class Foo
    {
        Foo();
    };
    
    // Note that the header file INCLUDES the cpp file. This is simply to maintain
    // the general .h .cpp file structure, but adapt it to template code, where the
    // implementation is supposed to be in the header file and is not compiled.
    #include "Foo.cpp"
    
    #endif
    

    Foo.cpp:

    // Note that I do NOT include the header here. Also, do NOT compile this file.
    // So if you have a makefile, be sure not to include this file in it.
    template <class T>
    Foo<T>::Foo()
    { }
    

    Or you can just stick the entire implementation in the header file and not have a cpp file at all. This would actually make more sense because you do NOT compile the cpp file. Read more here.

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

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.