|
![](/i/fill.gif) |
Nieminen Juha wrote:
> How do you get more than one value returned from a method in C++?
> Of course you can get a class (or struct) instance, but it's still just one
> value.
Easily:
int foo( int &out1, int &out2, int &out3, int in1 );
Most any Win32 COM stuff starts to act like that.
Here's the IDL stuff on the basic IDispatch interface. The invoke one is a call worth
noticing.
interface IDispatch : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(
/* [out] */ UINT __RPC_FAR *pctinfo) = 0;
virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(
/* [in] */ UINT iTInfo,
/* [in] */ LCID lcid,
/* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo) = 0;
virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(
/* [in] */ REFIID riid,
/* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
/* [in] */ UINT cNames,
/* [in] */ LCID lcid,
/* [size_is][out] */ DISPID __RPC_FAR *rgDispId) = 0;
virtual /* [local] */ HRESULT STDMETHODCALLTYPE Invoke(
/* [in] */ DISPID dispIdMember,
/* [in] */ REFIID riid,
/* [in] */ LCID lcid,
/* [in] */ WORD wFlags,
/* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
/* [out] */ VARIANT __RPC_FAR *pVarResult,
/* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
/* [out] */ UINT __RPC_FAR *puArgErr) = 0;
};
and you might get something like this in the header files:
#define
IDispatch_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
\
(This)->lpVtbl ->
Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
You can do things a little like that in Java, but you have to really work hard to do
so.
> I'm not saying that Java is a bad language. It's safer and often more
> pleasant to look at than C++. It's harder to make bad programming with it
> (although possible).
> I just don't like the limits it imposes. Sorry :)
Then you know the tasks you need to acomplish, and have made good evaluations based on
that.
A good programmer knows when to use which tools.
--
"My new computer's got the clocks, it rocks
But it was obsolete before I opened the box" - W.A.Y.
Post a reply to this message
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
In article <38D08B07.7587F6E4@ij.net>, Matt Giwer <jul### [at] ij net>
wrote:
> Maybe you have not looked around? There are enough free ones out
> there that I could make an 18-wheeler and have spares. Ain't a
> dime's worth of difference among them in my never humble opinion.
I know there are a lot of free parser frameworks/libraries, I would
prefer to use a fairly standardized one like Flex/Bison or write one of
my own which I could understand. I plan on looking into Flex and Bison
to see if they have what I need.
> > While those might be good for people who want rapid development, I am
> > not sure they would apply in my case. I do think there is a set of
> > Bison/Flex(or is it Flexx?) tools for CodeWarrior, but I have never
> > used
> > that kind of thing.
>
> Not quite the same thing. In the days of patchpanels it was
> considered a daunting task just to parse words (trailing
> whitespace) properly. That turned out to be simple. Praise the
> lord and pass the card deck.
Not quite the same thing as what? They are parser tools...I need a
parser, and I would prefer to know how they work in some detail first.
> Converting infix to postfix notation to machine language turned
> out to be easy also. Doing so efficiently turned out to be a
> bitch and half. How many passes does your compiler make?
Which compiler, the one I develop in C/C++ on? I really have no idea.
And what does this have to do with C-SDL?
> > Actually, I don't have it. All the books I have are a couple standard
> > "learn C++" books:
> > Teach Yourself C++ in 21 Days(got this when I took C++ at school)
> > Programming with C++
> > Rescued by C++
> > C++ Primer Plus(this one is actually my favorite, I rarely use the
> > others)
> > And a couple C and Java books, and one Pascal book(also from a class I
> > took at school).
>
> That is something else entirely. The theory and practice of
> compilers vice parsers (which are more like tokenizers in BASIC)
> is something else entirely. Think about it. Everything you write
> has to get to machine code instructions.
Something else entirely from *what*? I listed the books I had, said they
were mostly for learning the languages, and said I don't have any books
on parsers or other algorithms.
And compilers don't interest me, nothing I do goes to machine code
instructions except as data(and I can ignore the fact that my C++ code
is converted to machine code), the only thing my program would do is
convert C-SDL to POV-Script.
> > I don't have any books on algorithms or programming theory. I don't
> > have much money to buy them either... :-(
> No library?
No good ones nearby, unfortunately. I don't live in a remote,
unpopulated area, but we are a relatively long way from that kind of
thing. And no transportation other than my parents, although I will be
taking drivers training in June.
--
Chris Huff
e-mail: chr### [at] yahoo com
Web page: http://chrishuff.dhs.org/
Post a reply to this message
|
![](/i/fill.gif) |