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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:51:02+00:00 2026-05-23T01:51:02+00:00

Can someone pelase explain to me how I can avoid the error below? I

  • 0

Can someone pelase explain to me how I can avoid the error below?

I think I am following all I have read on template compilation but still get an error. Sorry for asking this – it seems trivial but I am stuck!

Thanks,
Paolo

1>------ Build started: Project: BitsAndPieces, Configuration: Release Win32 ------
1>  NonTemplateFunctionFriend_main.cpp
1>NonTemplateFunctionFriend_main.obj : error LNK2001: unresolved external symbol "public: int __thiscall Paolo<int>::getMyOnlyMember(void)" (?getMyOnlyMember@?$Paolo@H@@QAEHXZ)
1>\\na-13\agnolucp\my documents\visual studio 2010\Projects\BitsAndPieces\Release\BitsAndPieces.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

main

#include "NonTemplateFunctionFriend.h"
#include<iostream>
using namespace std;


int main() { 
    Paolo<int> Me;
    cout << Me.getMyOnlyMember() << endl;
    return 1;
}

NonTemplateFunctionFriend.h

#ifndef NonTemplateFunctionFriend_H
#define NonTemplateFunctionFriend_H

    #include <iostream>

    template<class T> class Paolo {

    private:
        T myOnlyMember;
    public:
        Paolo(): myOnlyMember(1000) {};
        T getMyOnlyMember();
    };

    #include "NonTemplateFunctionFriend.cpp"

#endif

NonTemplateFunctionFriend.cpp

#ifndef NonTemplateFunctionFriend_CPP
#define NonTemplateFunctionFriend_CPP

    #include "NonTemplateFunctionFriend.h"

    template<class T>   T getMyOnlyMember() {
            return myOnlyMember;
    }


#endif
  • 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-23T01:51:03+00:00Added an answer on May 23, 2026 at 1:51 am

    You can separate the file as long as you’re including it inside the header file (templates must be fully defined within the same translation unit, lacking proper support for the export keyword).

    But you’re not qualifying your function definition with the class

    Paolo<T>::
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please explain to me the below code. This behavior has been like
Can someone please explain to me once and for good what are Session Key
Can someone please explain to me what goes to the Output window in VS?
Can someone please explain in detail what these if statements are doing? What does
Can someone please explain to me how to create an ASIHTTPRequest object that can
can someone please explain why the addition of the group by subquery makes this
Can someone please explain to me why my variable called activity is 0 when
I am editing a Perl file, but I don't understand this regexp comparison. Can
I'm trying to make a landscape app that uses navigation controller, but I can't
In matplotlib , I can set the axis scaling using either pyplot.xscale() or Axes.set_xscale()

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.