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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:26:00+00:00 2026-06-01T08:26:00+00:00

I am trying to write a template class in C++ and getting this strange

  • 0

I am trying to write a template class in C++ and getting this strange linker error and can’t figureout the cause, please let me know whats wrong with this!

Here is the error message I am getting in Visula C++ 2010.

1>------ Rebuild All started: Project: FlashEmulatorTemplates, Configuration: Debug Win32 ------
1>  main.cpp
1>  emulator.cpp
1>  Generating Code...
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall flash_emulator<char>::flash_emulator<char>(char const *,struct FLASH_PROPERTIES *)" (??0?$flash_emulator@D@@QAE@PBDPAUFLASH_PROPERTIES@@@Z) referenced in function _main
1>C:\Projects\FlashEmulator_templates\VS\FlashEmulatorTemplates\Debug\FlashEmulatorTemplates.exe : fatal error LNK1120: 1 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Error message in g++

main.cpp: In function âint main()â:
main.cpp:8: warning: deprecated conversion from string constant to âchar*â
/tmp/ccOJ8koe.o: In function `main':
main.cpp:(.text+0x21): undefined reference to `flash_emulator<char>::flash_emulator(char*, FLASH_PROPERTIES*)'
collect2: ld returned 1 exit status

There are 2 .cpp files and 1 header file, and I have given them below.

emulator.h

#ifndef __EMULATOR_H__
#define __EMULATOR_H__

typedef struct {
    int property;
}FLASH_PROPERTIES ;

/* Flash emulation class */
template<class T>
class flash_emulator
{
private:
    /* Private data */
    int key;    

public:
    /* Constructor - Opens an existing flash by name flashName or creates one with 
       given FLASH_PROPERTIES if it doesn't exist */
    flash_emulator( const char *flashName, 
                       FLASH_PROPERTIES *properties );

    /* Constructor - Opens an existing flash by name flashName or creates one with 
       given properties given in configFIleName */
    flash_emulator<T>( char *flashName, 
                       char *configFileName );

    /* Destructor for the emulator */
    ~flash_emulator(){
    }
};

#endif  /* End of __EMULATOR_H__  */

emulator.cpp

#include <Windows.h>
#include "emulator.h"

using namespace std;


template<class T>flash_emulator<T>::flash_emulator( const char *flashName, 
                                                    FLASH_PROPERTIES *properties ) 
{
    return;
}

template<class T>flash_emulator<T>::flash_emulator(char *flashName,
                                char *configFileName)
{
    return;
}

main.cpp

#include <Windows.h>
#include "emulator.h"

int main()
{
    FLASH_PROPERTIES properties = {0};
    flash_emulator<char> myEmulator("C:\newEMu.flash", &properties);

    return 0;
}
  • 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-01T08:26:02+00:00Added an answer on June 1, 2026 at 8:26 am

    You have to define template functions in visible headers.

    Move the definition of

    template<class T> flash_emulator<T>::flash_emulator( const char *flashName, 
                                       FLASH_PROPERTIES *properties )
    

    and

    template<class T> flash_emulator<T>::flash_emulator(char *flashName,
                                char *configFileName)
    

    from emulator.cpp into emulator.h.

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

Sidebar

Related Questions

I keep getting the following error when trying to write a template function: main.cpp|17|error:
noob here still experimenting with templates. Trying to write a message processing class template
I am trying to write a generic one-size-fits-most repository pattern template class for an
I am trying to write a thread safe logger class so that i can
I am trying to write graph class as a template class. As answered in
I'm trying to write some dimension-independent code for a template class in c++, using
I am trying to write a class template that provides a comparison operator between
I'm trying to write a conversion operator function template in a class and running
I am trying to write a trivial Matrix class, using C++ templates in an
I'm trying to write a custom rendering template for use in the DisplayForm of

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.