473,320 Members | 1,821 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,320 software developers and data experts.

Right return

This is a typical way to get a return from a function

#define MY_PROC_ERR 0
#define MY_PROC_PARTIAL_SUCCESS 1
#define MY_PROC_FULL_SUCCESS 2

int CSomeClass::MyProc(...)
{
//Do processing
return iRet;
}

void CAnotherClass::OnProc
{
CSomeClass someclass_object;
switch(someclass_object.MyProc(...))
{
case MY_PROC_ERR:
ShowError();
break;
case MY_PROC_PARTIAL_SUCCESS:
Do AdditionalProcessing(...);
break;
case MY_PROC_FULL_SUCCESS:
Finish();
break;
}
}

Do you know a better way? Small improvements like using enum are not
suffice

Thanks

Alex
Jul 19 '05 #1
3 1729
WW
Alex Tenenboym wrote:
This is a typical way to get a return from a function

#define MY_PROC_ERR 0
#define MY_PROC_PARTIAL_SUCCESS 1
#define MY_PROC_FULL_SUCCESS 2
int const MyProcErr etc. C++ is not C. And the whole thing goes inside
CSomeClass.
int CSomeClass::MyProc(...)
{
//Do processing
return iRet;
}
???
void CAnotherClass::OnProc
{
CSomeClass someclass_object;
switch(someclass_object.MyProc(...))
{
case MY_PROC_ERR:
ShowError();
break;
case MY_PROC_PARTIAL_SUCCESS:
Do AdditionalProcessing(...);
break;
case MY_PROC_FULL_SUCCESS:
Finish();
break;
}
}

Do you know a better way? Small improvements like using enum are not
suffice


You need to post code which show what you are trying to do. What is partial
success? And if it is onyl partially successfull why don't you retry it
after the additional processing?

Unless we know what error and partial success means there is no way we can
give a good advice.

--
WW aka Attila
Jul 19 '05 #2
Alex Tenenboym <al*****@bigfoot.com> wrote in message
news:97**************************@posting.google.c om...
This is a typical way to get a return from a function

#define MY_PROC_ERR 0
#define MY_PROC_PARTIAL_SUCCESS 1
#define MY_PROC_FULL_SUCCESS 2
I hope these #defines are no longer typical. An enum or const ints would be
better.
int CSomeClass::MyProc(...)
{
//Do processing
return iRet;
}

void CAnotherClass::OnProc
{
CSomeClass someclass_object;
switch(someclass_object.MyProc(...))
{
case MY_PROC_ERR:
ShowError();
break;
case MY_PROC_PARTIAL_SUCCESS:
Do AdditionalProcessing(...);
break;
case MY_PROC_FULL_SUCCESS:
Finish();
break;
}
}

Do you know a better way? Small improvements like using enum are not
suffice


"Better" how? Assuming you are doing the right thing in each case, this code
is clear and maintainable. What more do you want?

DW

Jul 19 '05 #3

"Alex Tenenboym" <al*****@bigfoot.com> wrote in message
news:97**************************@posting.google.c om...
This is a typical way to get a return from a function

#define MY_PROC_ERR 0
#define MY_PROC_PARTIAL_SUCCESS 1
#define MY_PROC_FULL_SUCCESS 2

int CSomeClass::MyProc(...)
{
//Do processing
return iRet;
}

void CAnotherClass::OnProc
{
CSomeClass someclass_object;
switch(someclass_object.MyProc(...))
{
case MY_PROC_ERR:
ShowError();
break;
case MY_PROC_PARTIAL_SUCCESS:
Do AdditionalProcessing(...);
break;
case MY_PROC_FULL_SUCCESS:
Finish();
break;
}
}

Do you know a better way? Small improvements like using enum are not
suffice


Huh? A "better" way to return a value from a function? Your question is
unclear.
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: yaktipper | last post by:
This explains how to disable the view source / right-click menu in Netscape 4, Netscape 6 and Internet Explorer (IE). <script language="JavaScript"> //This code is the beginning of the right...
8
by: George Hester | last post by:
In a page I have when the user left-clicks the page a Input box for a form gets the focus. But if the user right-clicks the page the Input box is not getting the focus. I'd like the Input box to...
5
by: Someone | last post by:
I know many don't like having right click disabled, however this is a unique case where clients using viewing this particular site will not be world wide so it's not going to affect too many...
22
by: Simon | last post by:
Hi, I have written a function to trim char *, but I have been told that my way could be dangerous and that I should use memmove(...) instead. but I am not sure why my code could be 'dangerous'...
3
by: deanfamily11 | last post by:
Ok, here's another problem I'm having. I've tried several different things, but I just can't get anything to be right justified. Any thoughts? #include <iostream> #include <iomanip>...
12
by: Mick_fae_Glesga | last post by:
OK, the solution to this is probably blindingly obvious to everyone, but... surely it can't be right. I am compiling with borland bcc32 free compiler this piece of code is designed to identify...
25
by: johnmsimon | last post by:
i need to develop a code that finds a prime right number between 2 and 100000. and print one line of text that indicates if the int. is right prime. i am in beginning programing so complex is...
1
by: innermostsecret | last post by:
i am using dreamweaver 8 to build my site. i want to put a code in that stops people from viewing my page source and right clicking on the page. i did a google to find a code for this and used it. ...
0
by: Egor Zindy | last post by:
Egor Zindy wrote: #!/usr/bin/env python """ A generic chipid library based on ctypes This module handles most of the functions in FTChipID.dll
52
by: marc | last post by:
Hello, Is it possible to right pad with "0" (or other character != blank) ? for example : 1 , length 10 ="1000000000" I've tried with sprintf but I can only left pad with "0" or right pad with...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.