Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C++ Queries

Posted on 2004-04-20
3
Medium Priority
?
216 Views
Last Modified: 2006-11-17
Q1)If Base class is to be abstract but none of the virtual member functon can be reasonably required to be pure then which of the following is the best choice to make a pure virtual function and why?
Default Constructer,Copy Constructer,Destructor,Assignment operator


Q2)Is this works Derived** to Base**
a)It will work ,b)Run time error c)Compiler error

I want the answers of the above questions, Moreover Can u please tell me from where I can find
these type of programming brain teasers

Sebnak
0
Comment
Question by:sebnak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 60 total points
ID: 10867912
Q1: Default Constructer,Copy Constructer,Destructor,Assignment operator

None of them can be made pure virtual. Constructors never are virtual (because there is no instance where virtuality could work on), destructor may be virtual but not pure virtual (as all destructors get called) and operators can not be virtual.

Q2: Compile error. However, that compiles:

    Derived   d;
    Derived*  pd = &d;
    Derived** ppd = &pd;
    Base*     pb  = pd;
    Base**    ppb = &pb;


>> these type of programming brain teasers

Don't know what you mean exactly?

Regards, Alex


0
 
LVL 2

Expert Comment

by:sin_
ID: 10876996
1. For your 1st question, use the virtual destructor.

Though you make it pure, you still need to provide the body for it. Otherwise, it will give you a linking problem.

2.  You gotta use the dynamic_cast for it.

Hope this helps
0
 
LVL 7

Expert Comment

by:jj819430
ID: 10878283
Homework
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question