473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

pass Enumeration to function in c++

hi
i have a class named SocketInfo.
in this class i declare an enum type :
class SocketInfo
{
public:
typedef enum SocketTypeEnum
{
#define SOCKET_TYPE_IPSEC (0x0001 <<8)
}
SocketType;

SocketInfo(SocketInfo::SocketType stype)
}

when i want to use class in the test app(it is win32 consol application) and pass the constructor enum as :
SocketInfo* si = new SocketInfo(SocketInfo::SOCKET_TYPE_IPSEC)

i got this error :
Error 3 error C2589: '(' : illegal token on right side of '::'
Error 4 error C2059: syntax error : '::'

by passing it as

SocketInfo* si=new SocketInfo(SOCKET_TYPE_IPSEC)

i got this error :
Error 3 error C2664: 'SocketInfo::SocketInfo(const char *,unsigned short,SocketInfo::SocketType)' : cannot convert parameter 3 from 'int' to 'SocketInfo::SocketType'

these errors occure even when i declare enum type out side of class.

and also by changing constructor defnition to :
SocketInfo(SocketType stype)

i got same errors.

how i can solve this problem

thank you
Mar 29 '12 #1
1 2203
johny10151981
1,059 1GB
#define SOCKET_TYPE_IPSEC (0x0001 <<8)

its a macro, and its never member of SocketTypeEnum.

either write it this
Expand|Select|Wrap|Line Numbers
  1. SOCKET_TYPE_IPSEC (0x0001 <<8)
or
Expand|Select|Wrap|Line Numbers
  1. SocketInfo* si = new SocketInfo(SOCKET_TYPE_IPSEC)
  2.  
Mar 30 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Yangang Bao | last post by:
I have a simple test program. It doesn't work. I want to know what is the reason and how to fix it. Maybe I should use template function to do it. But I don't know how. Here is the simple...
6
by: _andrea.l | last post by:
I'd like to write a function like: function f(){ ... bla ...} f_example(f); function f_example($function_to_execute) {...bla... $function_to_execute() ...bla....} AND how to pass the...
2
by: Ronnie Smith | last post by:
I am trying to pass a function (method) address to a user control to associate with an event. The small user control which sends events is contained in a larger user control group which is in...
6
by: Minfu Lu | last post by:
I have a problem dealing with passing a function address to a COM callback. I use this COM function for communicating to a hardware. My original project was written in VB. I have converted it to...
4
by: _Mario.lat | last post by:
Hallo, I have a little question: In the function session_set_save_handler I can pass the name of function which deal with session. In Xoops code I see the use of this function like that: ...
8
by: Leo jay | last post by:
dear all, i want to write log on disk file when macro NEED_DO_LOG is defined. otherwise, do nothing. so i wrote code like this: #ifdef NEED_DO_LOG fstream fsLogFile (...); #else CDummyStream...
8
by: laredotornado | last post by:
Hi, I want to pass my function myFunc('a', 'b', 'c') as an argument to another function. However, this will not work doStuff('x', 'y', myFunc('a', 'b', 'c'))
1
by: shalini jain | last post by:
Hi, I am facing the problem with eval function. I want to know how to pass a function in eval() when we have to create the function itself. I would better explain my problem with the help of an...
4
by: mwanstall | last post by:
Hi All, I have started tearing my hair out over this problem! I am pulling some data from a table and passing it as variables into a function in Access. One of the variables I'm passing through...
10
by: iskhan | last post by:
Is it possible that pass a function name as a argument in an other function? e.g. MainMenu($SubMenu) { //Main menu designing start if(.......&&......||.......&&.......) { $this->$Submenu;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.