home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!sol.ctr.columbia.edu!caen!uakari.primate.wisc.edu!ames!agate!forney.berkeley.edu!jbuck
- From: jbuck@forney.berkeley.edu (Joe Buck)
- Newsgroups: comp.lang.c++
- Subject: Re: a few rookie questions about testing for CLASSS membership.
- Message-ID: <17hdhdINNgjv@agate.berkeley.edu>
- Date: 27 Aug 92 02:09:49 GMT
- References: <1992Aug25.204448.15682@cs.wisc.edu>
- Organization: U. C. Berkeley
- Lines: 36
- NNTP-Posting-Host: forney.berkeley.edu
-
- In article <1992Aug25.204448.15682@cs.wisc.edu> roth@ordin.cs.wisc.edu (Bill Roth) writes:
- >
- >I'm a relative rookie to C++, though not to OOP (due to many moons of
- >programming in Objective-C).
-
- Learning C++ won't be just a matter of learning new syntax in that case.
- C++ is a strongly typed language; Objective-C is not. There's a tradeoff
- in this; C++ will catch many more errors at compile time, but certain
- things are more difficult to do.
-
- >1. I have a pointer p to some object. How do I test if p is a member
- >of the CLASS a.
-
- There's no builtin way to do this, and programs that depend on the ability
- to do so are against the C++ philosophy. If you must do it (and sometimes
- you must) you can add a method that returns the type.
-
- >2. Is there a way to test if p, which is a pointer to an object, can
- >test if p can execute method m?
-
- Since C++ is a strongly typed language, your program fails to compile if p
- cannot execute method m.
-
- To understand the distinction between the C++ model of types and that of
- Smalltalk (which is very close to that of Objective-C), I suggest reading
- Chapter 12 of Stroustrup's "The C++ Programming Language, 2nd edition".
-
- I'm not going to tell you that C++'s model is better or worse than that of
- Smalltalk. But it's very different; so much so that you're going to have
- to "re-learn" a great deal.
-
-
-
-
- --
- Joe Buck jbuck@ohm.berkeley.edu
-