AceTheInterview
Jobs in Pune | Work better in teams | Socialize with friends | Submit Q&A | Tell a friend
Search site for 

Top 100 Interview Questions & Answers in a convenient and easy to read book!

“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”

– Ravi, California

Read more comments...

Interview Questions And Answers RSS Feed

Answers »

  1. Submitted By: Arvind — December 5, 2006
    +28 votes
      + -

    Compile error: no matching function B::func()

    Also note that func is private.

  2. Submitted By: Pranav — December 5, 2006
    +7 votes
      + -

    the output will be the compile error because B doent know the defination of func().

    To make this program run .it should be like

    Class A
    {
    public:
    void func();
    };
    class B:pubic A
    {
    using A::func();
    void func(int a);
    };
    int main()
    {
    B derv;
    derv.func();
    }

  3. Submitted By: Megha — December 7, 2006
    +2 votes
      + -

    there will be a compilation error bcoz A::func() is only declared but not defined anywhere. wen derv.func() is called , A::func() is called as it is publicly inherited from class A . B::func() can’t be called from main as it is private & also bcoz its prototype is different.

    using A::func() can only be used if class B was privately inherited from A.

  4. Submitted By: Abul Asim M. R. Qarshi — December 8, 2006
    -5 votes
      + -

    well its overloading instead or overriding.. so method will be called of the base class that is A.

    calling derv.func() will invoke A::func()

  5. Submitted By: raj malhotra — January 1, 2007
    -2 votes
      + -

    the output will be compiler error because the func() has no defintion

  6. Submitted By: ankit — January 4, 2007
    -6 votes
      + -

    this program contains the concept of function overloading!
    error will be there-too few parameters passed in derv::func(int x) !

  7. Submitted By: MikeS — January 18, 2007
    +1 votes
      + -

    compiler complains of syntax errors:
    Class A // upper case C
    class B:public A // what is a “pubic”

  8. Submitted By: lalitha — January 23, 2007
    +0 votes
      + -

    We get syntax error;
    here we are using overloading of function method but without function definition;
    so we ge error like this
    `class B derv’ has incomplete type and cannot be initialized

  9. Submitted By: Suvigya — February 1, 2007
    +0 votes
      + -

    It is an error as we have not defined function func() and a private function of Class B cannot be invoked from Main(). This is absurd!

  10. Submitted By: RK — May 3, 2007
    +0 votes
      + -

    The compiler will give following error

    Error: B::func(int) is not accessible from main().
    Too few arguments in call to “B::func(int)”.

  11. Submitted By: HXia — May 20, 2007
    +1 votes
      + -

    If ignore the typo and suppose the functions are defined somewhere.

    The derv.func(); will invoke A::func(). because:

    A::func()
    B::func(int a)

    are two different functions. A::func() is public. Sure the main return integer, but there is no return clause?

  12. Submitted By: vikram bhat — May 21, 2007
    +0 votes
      + -

    there will be compilation error because function overloading will not work for inheritance.
    even if you want it to work you must include the following code line in derived class.
    A::func();

    ofcourse the function needs to be public

  13. Submitted By: Siyad — May 23, 2007
    +3 votes
      + -

    Friends,

    For your reference this is what MS VC compiler gives :’func’ : function does not take 0 parameters.

    I believe the reason is, name hiding in C++. If you have same named identifier in two scopes. The later will hide the former. Eg. if you have variable X on global scope and a same named variable X there in one of the function scope, then the later will have previllage over the global one. And same applies to the functions too.

  14. Submitted By: anuthubn — May 25, 2007
    -2 votes
      + -

    The derv.func(); will invoke A::func(). because:

    A::func()
    B::func(int a)

    are two different functions. A::func() is public

  15. Submitted By: unknown — June 28, 2007
    -1 votes
      + -

    How can you create an object of an abstract class?

  16. Submitted By: FanZai — July 3, 2007
    +1 votes
      + -

    int main()
    return type is int, but no return;

  17. Submitted By: santhosh Kumar — July 13, 2007
    not yet rated
      + -

    line 6: class B:pubic A

    pubic A or public A?

  18. Submitted By: Bhabani Shankar — July 30, 2007
    +1 votes
      + -

    Overloading concept is applicable within the same scope. Hence it is irrevalent to overload the base class functions within derived classes. The concept of overriding of functions should be used for this sort of requirements.

  19. Submitted By: Muhammad Ishaq — September 19, 2007
    +1 votes
      + -

    Well, I have read all the answers above, and as already been said, func() is not visible because func(int a) has hidden it. (you can’t say that func(int a) is just an overloaded version of func(), overloading works in the same scope). To make it work, you have to provide a corresponding void func() in B and inside that you can call A::func();

  20. Submitted By: Herojeet — October 25, 2007
    not yet rated
      + -

    The answer suggested by “Muhammad Ishaq” is correct and verified. Assuming typo and other minor errors

  21. Leave an Answer/Comment

    To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
    Click to hear an audio file of the anti-spam word

Our Sponsors
Our Sponsors
Contact Us | FAQ | Sitemap | Terms of Use | Privacy Policy | Tell a Friend

Copyright © 1999-2006 Jeeve Technologies LLC. All rights reserved.