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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:56:15+00:00 2026-06-15T15:56:15+00:00

In the following: int c[10] = {1,2,3,4,5,6,7,8,9,0}; printArray(c, 10); template< typename T > void

  • 0

In the following:

int c[10] = {1,2,3,4,5,6,7,8,9,0};

printArray(c, 10);

template< typename T >
void printArray(const T * const array, int count)
{
    for(int i=0; i< count; i++)
        cout << array[i] << " ";
}

I am a little confused why the function signature of the template function makes no reference to array being an array by using [], so something like const T * const[] array.

How could one tell from the template function signature that an array is being passed and not just a non-array variable??

  • 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-15T15:56:16+00:00Added an answer on June 15, 2026 at 3:56 pm

    You cannot tell for sure. You would have to read the documentation and/or figure it out from the names of the function parameters. But since you are dealing with fixed sized arrays, you could have coded it like this:

    #include  <cstddef> // for std::size_t
    
    template< typename T, std::size_t N >
    void printArray(const T (&array)[N])
    {
        for(std::size_t i=0; i< N; i++)
            cout << array[i] << " ";
    }
    
    int main()
    {
      int c[] = {1,2,3,4,5,6,7,8,9,0}; // size is inferred from initializer list
      printArray(c);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following: int count = args.length; Strange as it might seem I
Suppose I declared an array as following: int myArr = [someSize]; Now I put
Is the following int BlkArray::GetNthBlockA(unsigned int n, const Block *&pfb, int &maxIndex) const {
What is the Method Signature in the following int DoSomething(int a, int b); Return
Can you please explain me the difference between mechanism of the following: int function();
Consider the following: int ival = 1.01; int &rval = 1.01; // error: non-const
I have to copy the following int array in to Array : int[] intArray=new
I have the following : int R=25; double pi=3.14; double r=R*sqrt(rand()); cout<<r: <<r<<endl; double
Consider the following : int increment1 (const int & x) { return x+1; }
I just saw the signature for printf . it is int printf(const *f) .

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.