What is the difference between class A {}; class Z: public A {};  and class A {}; class Z: virtual public A {};
78578
I want to know what a "virtual base class" is and what it means.  Let me show an example:  class Foo { public:     void DoSomething() { /* ... */ } };  class Bar : public virtual Foo { public:     void DoSpecific() { /* ... */ } };
5757
When used like this:  import static com.showboy.Myclass;  public class Anotherclass{}   what's the difference between import static com.showboy.Myclass and import com.showboy.Myclass?
28775
Is it better to initialize class member variables on declaration  private List&lt;Thing&gt; _things = new List&lt;Thing&gt;(); private int _arb = 99;   or in the default constructor?  private List&lt;Thing&gt; _things; private int _arb;  public TheClass() {   _things = new List&lt;Thing&gt;();   _arb = 99; }   Is it simply a matter of style or are there performance trade-offs, one way or the other?
54427
I have two classes: Action and MyAction. The latter is declared as:  class MyAction extends Action {/* some methods here */}   All I need is method in the Action class (only in it, because there will be a lot of inherited classes, and I don’t want to implement this method in all of them), which will return classname from a static call. Here is what I’m talking about:  Class Action {  function n(){/* something */} }   And when I call it:  MyAction::n(); // it should return "MyAction"   But each declaration in the parent class has access only to the parent class __CLASS__ variable, which has the value “Action”.  Is there any possible way to do this?
51146
Here is an example of polymorphism from  (edited for readability):  // abstract base class #include &lt;iostream&gt; using namespace std;  class Polygon {     protected:         int width;         int height;     public:         void set_values(int a, int b) { width = a; height = b; }         virtual int area(void) =0; };  class Rectangle: public Polygon {     public:         int area(void) { return width * height; } };  class Triangle: public Polygon {     public:         int area(void) { return width * height / 2; } };  int main () {     Rectangle rect;     Triangle trgl;     Polygon * ppoly1 = &amp;rect;     Polygon * ppoly2 = &amp;trgl;     ppoly1-&gt;set_values (4,5);     ppoly2-&gt;set_values (4,5);     cout &lt;&lt; ppoly1-&gt;area() &lt;&lt; endl; // outputs 20     cout &lt;&lt; ppoly2-&gt;area() &lt;&lt; endl; // outputs 10     return 0; }   My question is how does the compiler know that ppoly1 is a Rectangle and that ppoly2 is a Triangle, so that it can call the correct area() function? It could find that out by looking at the "Polygon * ppoly1 = &rect;" line and knowing that rect is a Rectangle, but that wouldn't work in all cases, would it? What if you did something like this?  cout &lt;&lt; ((Polygon *)0x12345678)-&gt;area() &lt;&lt; endl;   Assuming that you're allowed to access that random area of memory.  I would test this out but I can't on the computer I'm on at the moment.  (I hope I'm not missing something obvious...)
73638
Is there any advantage over using a class over a struct in cases such as these?  (note: it will only hold variables, there will never be functions)  class Foo {  private:       struct Pos { int x, y, z }; public:        Pos Position;  };   Versus:  struct Foo {    struct Pos { int x, y, z } Pos; };     Similar questions:
97448
For example:  public class A : A.B {     public class B { } }   Which generates this error from the compiler:     Circular base class dependency   involving 'A' and 'A.B'   I always figured a nested class behaved just like a regular class except with special rules concerning accessing the outer class's private members, but I guess there's some implicit inheritance occurring between the two classes?
107434
I was looking at the Proxy Pattern, and to me it seems an awful lot like the Decorator, Adapter, and Bridge patterns. Am I misunderstanding something? What's the difference? Why would I use the Proxy pattern versus the others? How have you used them in the past in real world projects?
90693
VC++ makes functions which are implemented within the class declaration inline functions.  If I declare a class Foo as follows, then are the CONSTRUCTOR and DESTRUCTOR inline functions?  class Foo  {     int* p; public:     Foo() { p = new char[0x00100000]; }     ~Foo() { delete [] p; } };  {     Foo f;     (f); }
62585
Given the following example, why do I have to explicitly use the statement b-&gt;A::DoSomething() rather than just b-&gt;DoSomething()?  Shouldn't the compiler's overload resolution figure out which method I'm talking about?  I'm using Microsoft VS 2005. (Note: using virtual doesn't help in this case.)  class A {   public:     int DoSomething() {return 0;}; };  class B : public A {   public:     int DoSomething(int x) {return 1;}; };  int main() {   B* b = new B();   b-&gt;A::DoSomething();    //Why this?   //b-&gt;DoSomething();    //Why not this? (Gives compiler error.)   delete b;   return 0; }
33547
If I have an abstract parent class like this:  abstract class Vehicle {     public Vehicle(Person driver) {         //     } }   and then I create a child class like this:  public class MagicCarpet extends Vehicle {     //this won't compile }   I encounter the following Compile Error:     Error: Parent class has no 0-argument constructor for implicit construction at line ... column ...   Obviously I can explicitly re-declare a constructor on the child class toget it to compile:  public class MagicCarpet extends Vehicle {     public MagicCarpet(Person driver) {         super(driver);     } }   But I feel this isn't DRY. Not sure what's actually going on under the covers here.  How can I get a constructor (other than the implicit 0-argument one) to be inherited by a child class?
15868
Why does this code:  class A {     public:          explicit A(int x) {} };  class B: public A { };  int main(void) {     B *b = new B(5);     delete b; }   Result in these errors:   main.cpp: In function ‘int main()’: main.cpp:13: error: no matching function for call to ‘B::B(int)’ main.cpp:8: note: candidates are: B::B() main.cpp:8: note:                 B::B(const B&)   Shouldn't B inherit A's constructor?  (this is using gcc)
34146
This is a .NET question for C# (or possibly VB.net), but I am trying to figure out what's the difference between the following declarations:  string hello = "hello";   vs.   string hello_alias = @"hello";   Printing out on the console makes no difference, the length properties are the same.
86079
I recall there is a difference between some methods/properties called directly on the  class, and the identically named methods/properties on the  property. (Might have been the RowCount/Count property for which I read this.) The difference is one of them disregards , and the other respects/uses it.  In this particular case I'm wondering about the difference between  and . I can imagine one of them actually removes all rows, and the other one just marks them as deleted.  So my question is, is there a difference between the two Clear methods, and if so what is the difference?  (Oh, this is for .NET 1.1 btw, in case the semantics changed from one version to another.)
16862
Why would you declare a method as "virtual".   What is the benefit in using virtual?
107554
Is it possible in C# to have a Struct with a member variable which is a Class type?  If so, where does the information get stored, on the Stack, the Heap, or both?
138
What is the main difference between an inner class and a static nested class in Java? Does design / implementation play a role in choosing one of these?