473,473 Members | 1,994 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

virtual feature in inheritance

2 New Member
Expand|Select|Wrap|Line Numbers
  1. class A
  2. {
  3. public:
  4. virtual void func1()
  5. void func2();
  6. };
  7. class B: public A
  8. {
  9. public:
  10. void func1(){cout << “fun1 in class B” << endl;}
  11. virtual void func2(){cout << “fun2 in class B” << endl;}
  12. };
Which methods are virtual? A::func1, B::func1, or B::func2?
Jul 6 '10 #1
2 1195
Banfa
9,065 Recognized Expert Moderator Expert
Which methods are virtual? A::func1, B::func1, or B::func2?
All of those.
Jul 6 '10 #2
anriliu
2 New Member
Yup, I agree.
Thanks
Jul 7 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Michael Winter | last post by:
Until about 5 minutes ago, I was happy with my knowledge of virtual functions - then I read "Mixing interface and functional inheritance" posted by Kevin L. earlier today. All of a sudden, I found...
18
by: nenad | last post by:
Wouldn't it be nice if we could do something like this: class Funky{ public: auto virtual void doStuff(){ // dostuff } };
0
by: cppsks | last post by:
Hello. I posted a question regarding this yesterday. I came up with the following solution but I am a little hesistant as to this solution having any side-effects that I am not aware of. The...
8
by: Ioannis Vranos | last post by:
Why this does not compile: class Sealed { friend class Fred; Sealed() { } }; class Fred: virtual Sealed
4
by: vineoff | last post by:
First, think I'm having an abstract class class C { public: virtual void f(); }; What is the difference between these two ways: class D : public C { ... } and class D : public virtual C {...
14
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
8
by: JPRoot | last post by:
Hi M. Jeffrey Tan, Just hopping you didn't forget me? :) Thanks JPRoot ----- \"Jeffrey Tan\" wrote: -----
3
by: Magne Ryholt | last post by:
I have a base class and a chain of derived classes. The base and its derived classes are all abstract except the last in chain (a concrete class). I want to provide some functionalities in the...
2
by: Vladimir_petter | last post by:
Hello All, I've fount that if I compile the same program using gcc and vc 2003 the same class E (see complete source bellow) has different size (on vc it is 4 bytes bigger). Digging into this...
5
by: Noah Roberts | last post by:
Is there anything that says that if you virtually inherit from one class you have to virtually inherit from anything you inherit from?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.