473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Virtual Class - why?

Hi

What is the purpose of declaring a class with a "Virtual" in front?
What is the benefit?

Thanks

Dec 19 '06 #1
7 4865
2005 wrote:
Hi

What is the purpose of declaring a class with a "Virtual" in front?
None.
What is the benefit?
The only effect is that the program won't compile, but I'd not count that as
benefit.

Dec 19 '06 #2

Rolf Magnus wrote:
2005 wrote:
Hi

What is the purpose of declaring a class with a "Virtual" in front?

None.
What is the benefit?

The only effect is that the program won't compile, but I'd not count that as
benefit.
I have it in the notes

"virtual class xxxx" (ignoring the case sensitiveness if there is
any).

Can someone clarify pls?

Dec 19 '06 #3
2005 wrote:
What is the purpose of declaring a class with a "Virtual" in front?

None.
What is the benefit?

The only effect is that the program won't compile, but I'd not count that
as benefit.

I have it in the notes

"virtual class xxxx" (ignoring the case sensitiveness if there is
any).
C++ is indeed case sensitive. The virtual keyword (as all C++ keywords)
would be written in all lowercase letters.
Can someone clarify pls?
Maybe you're talking about some other language. In standard C++, this simply
makes no sense.
Dec 19 '06 #4
2005 wrote:
[SNIP]
"virtual class xxxx" (ignoring the case sensitiveness if there is
any).
Wasn't that "virtual *base* class" ?
--
WW aka Attila
:::
Drag me, drop me, treat me like an object!
Dec 19 '06 #5

2005 wrote:
Rolf Magnus wrote:
2005 wrote:
Hi
>
What is the purpose of declaring a class with a "Virtual" in front?
None.
What is the benefit?
The only effect is that the program won't compile, but I'd not count that as
benefit.

I have it in the notes

"virtual class xxxx" (ignoring the case sensitiveness if there is
any).
Everything in C++ is case sensitive except for your comments.
The only time a virtual class is met in C++ is in virtual inheritance.
[25.8] What is the "dreaded diamond"?
http://www.parashift.com/c++-faq-lit...heritance.html

Dec 19 '06 #6
A virtual class would be a key in solving the diamond problem with multiple
inheritance, see
http://en.wikipedia.org/wiki/Diamond_problem

Hope this helps

Moon2
Dec 21 '06 #7
Moon2 wrote:
A virtual class would be a key in solving the diamond problem with multiple
inheritance, see
http://en.wikipedia.org/wiki/Diamond_problem
Virtual inheritance (there's no such thing as a virtual class, but we
all know what's meant by that term) MIGHT be a way to approach solving
such a problem if the problem arose because of a design error.
Unfortunately, there's a great deal of folklore about the "dreaded
diamond", etc. that's based on the assumption that deriving from the
same base through multiple paths must be an error. It's not necessarily so.

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
Dec 21 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

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 } };
3
by: Daniel Graifer | last post by:
Why doesn't c++ support virtual data? It supports class data of type pointer to function (that's what virtual functions really are). In terms of implementation, why can't I have other types of...
4
by: JKop | last post by:
I'm starting to think that whenever you derive one class from another, that you should use virtual inheritance *all* the time, unless you have an explicit reason not to. I'm even thinking that...
11
by: santosh | last post by:
Hello, I was going through the Marshal Cline's C++ FAQ-Lite. I have a doubt regarding section 33.10. Here he is declaring a pure virtual destructor in the base class. And again defining...
32
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
2
by: Heinz Ketchup | last post by:
Hello, I'm looking to bounce ideas off of anyone, since mainly the idea of using Multiple Virtual Inheritance seems rather nutty. I chalk it up to my lack of C++ Experience. Here is my...
11
by: Nindi73 | last post by:
A few days a ago I posted my code for a deep copy pointer which doesn't require the pointee object to have a virtual copy constructor. I need help with checking that it was exception safe and...
7
by: eric | last post by:
hello i'm confused by an example in the book "Effective C++ Third Edition" and would be grateful for some help. here's the code: class Person { public: Person(); virtual ~Person(); // see...
17
by: Jess | last post by:
Hello, If I have a class that has virtual but non-pure declarations, like class A{ virtual void f(); }; Then is A still an abstract class? Do I have to have "virtual void f() = 0;"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.