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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:46:15+00:00 2026-06-01T01:46:15+00:00

When the following project is compiled, I get the following compiler error: (Visual Studio

  • 0

When the following project is compiled, I get the following compiler error: (Visual Studio 2010)

1>usingclass.obj : error LNK2019: unresolved external symbol “public: static int __cdecl c1::arrSize(int * const)” (??$arrSize@H@c1@@SAHQAH@Z) referenced in function “public: void __thiscall usingclass::a(void)” (?a@usingclass@@QAEXXZ)

Code:

Headers:

c1.h

#pragma once
#include <array>
class c1
{
    c1(void);
    ~c1(void);
public:
    template<class T>
    static int arrSize(T arr[]);
};

usingclass.h

#pragma once
#include "c1.h"

class usingclass
{
public:
    usingclass(void);
    ~usingclass(void);
    void a();
};

Source files:

c1.cpp

#include "c1.h"

c1::c1(void)
{
}


c1::~c1(void)
{
}

template <class T>
int c1::arrSize(T arr[])
{
    return (sizeof(arr)/sizeof(arr[0]));
}

usingclass.cpp

#include "usingclass.h"

usingclass::usingclass(void)
{
}


usingclass::~usingclass(void)
{
}

void usingclass::a()
{
    int a[2] = {1,2};
    int b = c1::arrSize<int>(a);
}

How do I fix that?

  • 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-01T01:46:16+00:00Added an answer on June 1, 2026 at 1:46 am

    You need to move

    template <class T>
    int c1::arrSize(T arr[])
    {
        return (sizeof(arr)/sizeof(arr[0]));
    }
    

    inside c1.h.

    Template implementations must be visible to all translation units using that template (unless it’s specialized, and in your case it’s not).

    This solves the compiler error but the underlying issue is solved with Vaughn Cato’s answer. I missed that. You’ll still need the definition in the header.

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

Sidebar

Related Questions

Problem Description: Occassionally when debugging, I get the following error. I'm using visual studio
When I try to compile this project I get the following error. I would
When attempting to compile my C# project, I get the following error: 'C:\Documents and
I have a Visual Studio 2010 project that is targeted to .NET Framework 3.5.
I am working on a project in Visual Studio 2010 which is to produce
I have an MFC C++ project compiler under Visual Studio 2008. I'm adding a
I downloaded and compiled CppUnit to compile with Visual Studio 2010. After the conversion,
When I try to compile my c++ project using Visual Studio 2010 in either
(OS: Windows 7, Compiler: Visual Studio 2010 C++ compiler) I've got a correctly working
I get the following message in a VC6 project compile: OTE: WINVER has been

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.