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

The Archive Base Latest Questions

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

i am really confusing about how to pass an enum type to a function

  • 0

i am really confusing about how to pass an enum type to a function in c++.
i am googling and test all the soloutions presented but non of them solve my problem.
in the SocketInfo.h ,
i have an enum named SocketType that declared globally as :

    typedef enum SocketTypeEnum
{
    SOCKET_TYPE_IPSEC
} SocketType;

in the SocketInfo.h i have a class named SocketInfo :

class SocketInfo
{
public:
    SocketInfo(const char* ip,unsigned short fd,SocketType stype);
}

in the SocketInfo.cpp :

SocketInfo::SocketInfo(const char* ip, unsigned short fd,SocketType stype)
{
    //some work done here
}

i build this class without any error

now for test this class i create a win32 console application.in the _tmain i write this code

#include "SocketInfo.h"

void Test_Socket()
{
    SocketInfo* si = new SocketInfo(NULL,5060,SOCKET_TYPE_IPSEC);
}

int _tmain(int argc, _TCHAR* argv[])
{
    Test_Socket();
    getch();
    return 0;
}

after running above code i got these errors:

Error 4 error LNK2019: unresolved external symbol “public: __thiscall SocketInfo::SocketInfo(char const *,unsigned short,enum SocketTypeEnum)” (??0SocketInfo@@QAE@PBDGW4SocketTypeEnum@@@Z) referenced in function “void __cdecl Test_Socket(void)” (?Test_Socket@@YAXXZ)

Error 5 error LNK1120: 1 unresolved externals

how i can solve these errors.

all codes compile on visual studio 2010 Ultimate.

  • 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-01T11:31:33+00:00Added an answer on June 1, 2026 at 11:31 am

    The problem isn’t in how you pass the enum as parameter, which is ok, but that you don’t export symbols from your project or import them in your test project.

    You need to add the lib file generated by the project defining SocketInfo to the additional dependencies of the test project.

    You also need to export the class:

    _declspec(dllexport) class SocketInfo
    {
    public:
        SocketInfo(const char* ip,unsigned short fd,SocketType stype);
    };
    

    and import it in the test project with _declspec(dllimport). This duality is usually achieved through macros – look it up.

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

Sidebar

Related Questions

This is probably very simple but it's really confusing me. When I implement the
This is probably a really stupid newbie-sounding question to you developer type people, but
Caution: I know nothing about C++. I'm comfortable using C#, but this is confusing
Well, sorry about the confusing title but I'm having a slightly annoying problem with
This is really confusing me as I'm not doing anything with Strings. This is
I'm having a really confusing problem. I have a UIWebView that is contained within
The following code seemed really confusing to me since it provided two different outputs.The
I know it is really confusing. Let me explain: I want to open the
I'm new to iPhone development, and multiple views (xib or nib) are really confusing
sorry for the confusing title, its really hard for me to explain what i

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.