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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:54:12+00:00 2026-06-01T22:54:12+00:00

i have a stucture: template <class T> struct Array{ int days; T * M;

  • 0

i have a stucture:

template <class T> struct Array{
int days;
T * M;
Array( int size ) : days(size), M(new T[size])
{
}
~Array()
{
   delete[] M;
}
};

void currentDay();
void add(int,int,Array &);

and a class:

class Expe {
private:
    int hk;     //HouseKeeping
    int fo;     //Food
    int tr;     //Transport
    int cl;     //Clothing
    int tn;     //TelNet
    int ot;     //Others

 }

Class contructor is :

Expe::Expe() {
this->hk = hk;
this->fo = fo;
this->tr = tr;
this->cl = cl;
this->tn = tn;
this->ot = ot;
}

THE PROBLEM: in main function i can manipulate the structure with objects… using the setObj() function for example but when i try to define my functions in Controller or in Controller.h i get the fallowing error:

..\ListStruc.cpp:28:28: error: 'Array' is not a type
..\ListStruc.cpp: In function 'void add(int, int, int)':
..\ListStruc.cpp:31:4: error: request for member 'M' in 'A', which is of non-class type 'int'

EDIT:

void add(int cant, int tip,Array A){
//Adds to current day the amount to a specific type

A.M[currentDay]; // i try to use this object.
}
  • 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-01T22:54:14+00:00Added an answer on June 1, 2026 at 10:54 pm

    This declaration is incorrect:

    void add(int,int,Array &);
    

    Since Array is a class template, the add function needs to be a template as well:

    template <class T>
    void add(int,int,Array<T> &);
    

    Additionally, your definition of the add function takes the parameter by value, while the declaration takes the parameter by reference.

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

Sidebar

Related Questions

I have the following structure: template <class T> struct Array{ int lenght; T *
I have structure for storing callback function like this: template<class T> struct CommandGlobal :
I have a template class ArrayTemp that creates an array of pointers to type
In this I need C++ array class template, which is fixed-size, stack-based and doesn't
I have a class structure which is template<int T> class MyClass { public: MyClass(){};
We have a structure like below: template<size_t size> class Container{ public: char characters[size]; };
I have the following templated class structure struct TraitA{}; struct TraitB{}; template<typename trait> struct
If I have this structure: namespace A { template <Class T> struct Point {
I have a defined a simple template class. In this class I define a
I have a structure typedef struct myStruct_st { int a; }myStruct; It can be

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.