|
-
March 30th, 1999, 11:34 AM
#1
enums
I am attempting to pass a paramter using a enum variable.
Code Sample:
public:
enum something{THING1, THING2, THING3}
Passing
the_status = the_object.method(parameter1, parameter2, THING1, parameter3)
I have tried the CLASS::enum member way of reference, to no success.
The problem is trying to pass a variable(the enum member) without hardcoding the
enum member name.
If any one has a hint.
Thanks
Don Head
-
March 30th, 1999, 11:38 AM
#2
Don't understand
I'd be interested to see your actual code, as I don't see anything wrong with what you're doing. I do this all the time. But I'm confused by your statement, "...without hardcoding the enum member name." Do you really mean, "...without hardcoding a literal number?" If you don't want to type the enum member *name*, then I'm confused.
-
March 30th, 1999, 12:09 PM
#3
Re: Don't understand
the enum statement is :
enum ContractType {TempAssign, Contract, Request}
The call looks like:
the_status = the_loader.DumpContract(jobid, code, UpLoader::TempAssign, etc ...)
the ContractType is calculated out, and this enum value is passed to the DumpContract
method. It will not be possible to hardcode the 'UpLoader::TempAssign' parameter.
This,I assume it would have to be a variable of some type.
I hope this clears up the question
Thanks
Don
-
March 30th, 1999, 12:42 PM
#4
Keep trying
Sorry, I didn't mean this when I said, "actual code." I meant something that would supply a context. But better yet, how about saying what's wrong? I mean, you say that you do this "to no success." What's failing? Compiler error? Incorrect results?
Wait--do you mean you want to pass a variable to DumpContract() that indicates the contract type? If that's the case, then you'll need a field in your contract object that indicates the contract type. You can then pass that field into DumpContract(). Does this help at all?
-
March 30th, 1999, 12:53 PM
#5
Re: Don't understand
The declaration for DumpContract would be something like:
int DumpContract(int jobid, int code, enum ContractType type, .....
or the enum isn't really necessary but you might need:
int DumpContract(int jobid, int code, UpLoader::type, .....
Is this what you were looking for?
Who was that masked man?
-
March 30th, 1999, 03:33 PM
#6
Re: Keep trying
Here is some more code & the error message when compiled.
The caller will calculate the ContractCategoryType(based on various other fields)
using the enum,
DECLARATIONS in HH file:
public:
enum ContractCategoryType {TempAssignment, Contract, Request};
virtual Status DumpContract(int process_job_seq_id,
char trans_code,
int contract_id,
ContractCategoryType the_status,
ServiceStatusType the_status,
string service_type_code,
int cust_gsam_no,
string contract_reference,
string station_number,
char rec_del_type,
date billing_start,
date billing_end,
date renewal,
date termination,
date secondary_term,
int pipeline_log_code,
int pricePoint) const;
THE CALL
the_status = the_uploader.DumpContract(JobSeqId,
Code,
applSn,
contractCategoryType, <-- this causes the error in the compile
serviceStatusType, <-- this also causes errors
// UpLoader::TempAssignment, <-- hard coded works
// UpLoader::InProgress, <-- hard coded works
service,
GsamNo,
queuedString,
applStnNo,
recDelType,
billingStart,
billingEnd,
renewal,
termination,
junkDate,
SegCode,
pPoint);
THE ERROR MESSAGE:
QueuedService.cc: In method `class Status QueuedService: umpTo(const class UpLoader & ':
QueuedService.cc:184: bad argument 4 for function `class Status UpLoader: umpContract
(int, char, int, enum UpLoader::ContractCategoryType,
enum UpLoader::ServiceStatusType,
class basic_string<char,string_char_traits<char> >,
int, class basic_string<char,string_char_traits<char> >,
class basic_string<char,string_char_traits<char> >,
char, class date, class date, class date, class date,
class date, int, int) const' (type was class UpLoader)
make: The error code from the last command is 1.
(continuing)
Target "All" did not make because of errors.
Compilation exited abnormally with code 2 at Tue Mar 30 11:44:26
I thank you for your time.
-
March 30th, 1999, 05:55 PM
#7
How did you declare variables?
Ok, just one last vital piece of info is missing here: how did you declare the two variables contractCategoryType and serviceStatusType?
-
March 31st, 1999, 05:58 AM
#8
Re: Keep trying
> ContractCategoryType the_status,
> ServiceStatusType the_status,
Did you mean to have two arguments with the same name?
It would help to know how the contractCategoryType and serviceStatusType arguments are declared.
Dave
-
March 31st, 1999, 05:02 PM
#9
Re: Don't understand
I would like to thanks those that took the time to reply. I have figured it out.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|