Anda di halaman 1dari 3

5/31/2016 Interview.

C++ programming quick revision ­ C/C++ ­ Programming

» Forums Archive » Programming » C/C++ » Interview.C++ programming quick


revision
Last updated: 22 September 2010 narutis  Whirlpool Forums Addict

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

Any help would be appreciated. Time to get back to revision :)

ref: whrl.pl/RcridZ posted 2010­Sep­21, 3:15 pm

Lenny Pepperidge  Whirlpool Forums Addict

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 2010­Sep­21, 4:08 pm

narutis  Whirlpool Forums Addict

Burnouts writes... O.P.

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 2010­Sep­21, 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?

I won't do your homework, but those concepts can be easily googled.


From wikipedia, "In object-oriented programming theory, abstraction involves the facility to define
objects that represent abstract "actors" that can perform work, report on and change their state, and
"communicate" with other objects in the system. The term encapsulation refers to the hiding of state
details, but extending the concept of data type from earlier programming languages to associate
behavior most strongly with the data, and standardizing the way that different data types interact, is
the beginning of abstraction."
If you're really getting interviewed, you must be able to apply the wikipedia explanation to your
language.

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 2010­Sep­21, 6:08 pm (edited 2010­Sep­21, 6:42 pm)

gChTaCVr  Whirlpool Enthusiast

sassas writes...

Abstraction

A representation of a usable pattern.

Encapsulation

Hiding implementation details from other classes/objects.

polymorphism

Ability of a operation to change behaviour dependent on the type of its arguments.

Decoupling

Removing dependencies on external computations/data.

ref: whrl.pl/Rcrjk0 posted 2010­Sep­21, 7:05 pm

Kiwi Nick  Whirlpool Enthusiast

shinkee writes...

John should be (logically) a specific instance of human class, not a subclass.

+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

More Effective C++.

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 2010­Sep­21, 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 2010­Sep­22, 8:22 am

http://forums.whirlpool.net.au/archive/1538508 3/3

Anda mungkin juga menyukai