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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:58:15+00:00 2026-06-06T14:58:15+00:00

Im working on a template class which represents a managed Array. E (*data)[]; data

  • 0

Im working on a template class which represents a managed Array.

E (*data)[];

data is my array.

data = new E[size];

And this, it doesn’t like. it throws me;

cannot convert Component* to Component (*)[] in assignment
What gives?

Also can anyone explain why E is denoted with a * even though I didn’t pass a pointer type into my template type?

  • 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-06T14:58:17+00:00Added an answer on June 6, 2026 at 2:58 pm

    Just make your data member an E*. You will still be able to index array-style ala data[i] (that notation, when used with a pointer and integral value, basically means add the pointer and i times the size of the pointed-to objects).

    EDIT:

    template <typename E>
    class X
    {
        X(int initial_size) : data_(new E[initial_size]), size_(initial_size) { }
        X(const X& rhs) : data_(new E[rhs.size_]), size_(rhs.size_) { std::copy(...); }
        ~X() { delete[] data_; }
        void capacity(int new_size)
        {
            E* p = new E[new_size];
            std::copy(p, p + new_size, data_);
            delete[] data_;
            data_ = p;
            size_ = size;
        }
        ...
      private:
        E* data_;
        int size_;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a template class Array, which accepts another template TRAITS as
I ran across this code recently which is part of a template class: operator
I'm currently working on a new Magento template, and I'm facing problems with jQuery.
I'm working up a custom Xcode template, and I'd like to change the way
I'm testing the new template for a website that I'm working for, and on
I'm working on a template class and I've an issue when trying to parse
I am working with a CMS like system, phpBMS, which defines a certain way
Consider this simple class: template<class T> class Foo{ public: Foo(T const& val) : _val(val)
This one compiles and works like it should (non-nested template): #include <iostream> template<typename T>
Hya, Can anyone please tell me how this thing is working? template <typename T,

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.