C++ programming quick revision C/C++ Programming
I got a interview tomorrow and I would like to revise some of my c++ concepts. Just general O.P.
overall. I've already revised most of it. I was hoping if one of you could help me with it.
C++ being object oriented has classes and stuff. I understand classes, methods, and inheritance. A
class Human can have methods such as walk(), talk() etc. But a class on its own is nothing. If you want
to use it, you have to create an instance of it, hence allocating memory to it. And if you have sub
classes such as John. John class can inherit methods such as walk(), talk() from the Human class. This
helps because you dont have duplicate code. And sub classes that inherit from super clssses, they are
only able to use the methods and not see the data of the method. EG, John class can use the method
walk() but cant see what variables are used for that method. It is only able to send values to it and to
get a value back. Is this correct?
Could someone please explain the following object oriented concepts in plain english using the
Human and John classes?
1. Abstraction
2. Encapsulation
3. polymorphism
4. Decoupling
ref: whrl.pl/RcridZ posted 2010Sep21, 3:15 pm
sassas writes...
Could someone please explain the following object oriented concepts in plain english using the
Human and John classes?
Abstraction
Encapsulation
polymorphism
Decoupling
Interview or homework?
ref: whrl.pl/RcrivQ posted 2010Sep21, 4:08 pm
narutis Whirlpool Forums Addict
Interview or homework?
interview. I am just asking these questions because one of my last interviews asked me to briefly
explain these concepts. I am asking for laymans terms. If it was homework, teachers wouldn't want
http://forums.whirlpool.net.au/archive/1538508 1/3
5/31/2016 Interview.C++ programming quick revision C/C++ Programming
laymans answers.
ref: whrl.pl/Rcri01 posted 2010Sep21, 5:47 pm
Dark3001 Whirlpool Forums Addict
Burnouts writes...
Interview or homework?
+1 for me, it looks really like a homework (maybe an Object Oriented Programming course). It's
perfectly fine to write layman's term in homework.
Why would someone interview you anyway if you need whirlpoolian's help?
Edit: When I look back to your original post, your concept aren't even correct. John should be
(logically) a specific instance of human class, not a subclass. A subclass would be something like
Children, Teenager, Adult etc.
ref: whrl.pl/Rcri58 posted 2010Sep21, 6:08 pm (edited 2010Sep21, 6:42 pm)
gChTaCVr Whirlpool Enthusiast
sassas writes...
Abstraction
Encapsulation
polymorphism
Decoupling
ref: whrl.pl/Rcrjk0 posted 2010Sep21, 7:05 pm
shinkee writes...
+1
Another thing I'd advise is if you derive from a base class, make that class abstract. Not sure if the
interviewer will want to cover this kind of topic, but having instances of Human when you've got
subclasses as well opens up a whole bevvy of issues. More information in Scott Meyer's Effective C++ &
http://forums.whirlpool.net.au/archive/1538508 2/3
5/31/2016 Interview.C++ programming quick revision C/C++ Programming
One other thing specific to Human is that you'll need to provide a way to migrate a Child to a
Teenager and a Teenager to an Adult. Perhaps I can suggest the State pattern (from Design Patterns,
Gamma et al).
Nick.
ref: whrl.pl/RcrjvO posted 2010Sep21, 7:40 pm
Fenrisülvür Whirlpool Enthusiast
Yar, I can't see someone who is struggling to describe OO concepts landing a C++ job.
Anyway, a while back now I stumbled upon a thread elsewhere, within which a fair bit of C++ esoterica
landed. It was very interesting.
http://www.gamedev.net/community/forums/topic.asp?topic_id=553197
I also like Stroustrup's site, the C++ FAQ, and the FQA while we're at it:
http://www2.research.att.com/~bs/
http://www.parashift.com/c++-faq-lite/
http://yosefk.com/c++fqa/
The first two links there are invaluable resources for C++ programmers; the FQA is an interesting
"rebuttal" to the FAQ that's sure to inflame some, and can get a little obsessive at times. I think the
guy is often onto something, though.
ref: whrl.pl/Rcrk0n posted 2010Sep22, 8:22 am
http://forums.whirlpool.net.au/archive/1538508 3/3