27.10.2014 Views

Cracking the Coding Interview, 4 Edition - 150 Programming Interview Questions and Solutions

Cracking the Coding Interview, 4 Edition - 150 Programming Interview Questions and Solutions

Cracking the Coding Interview, 4 Edition - 150 Programming Interview Questions and Solutions

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Solutions</strong> to Chapter 13 | C++<br />

13.6 What is name hiding in C++?<br />

pg 76<br />

SOLUTION<br />

Let us explain through an example. In C++, when you have a class with an overloaded method,<br />

<strong>and</strong> you <strong>the</strong>n extend <strong>and</strong> override that method, you must override all of <strong>the</strong> overloaded<br />

methods.<br />

For example:<br />

1 class FirstClass {<br />

2 public:<br />

3 virtual void MethodA (int);<br />

4 virtual void MethodA (int, int);<br />

5 };<br />

6 void FirstClass::MethodA (int i) {<br />

7 std::cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!