this is example code that i got the error "undefined reference to`Parent::mMyClass'"  class Parent{ //A and B inherit Parent for mMyClass variable   protected:     enum MyClass{       ClassA,       ClassB,     };      static MyClass mMyClass; };  class A : Parent { public:     void setClass(){         mMyClass = Parent::ClassA; //Error Here     } }; class B : Parent { public:     void setClass(){         mMyClass = Parent::ClassB; //Error Here     } };  int main() {     A a;     B b;     a.setClass();     b.setClass();      return 0; }   I am trying to share the variable "mMyClass" to use for class A and B. Any solution for solving this problem in a better way? Thanks
1488
Can anyone explain why following code won't compile? At least on g++ 4.2.4.  And more interesting, why it will compile when I cast MEMBER to int?  #include &lt;vector&gt;  class Foo {   public:       static const int MEMBER = 1;   };  int main(){       vector&lt;int&gt; v;       v.push_back( Foo::MEMBER );       // undefined reference to `Foo::MEMBER'     v.push_back( (int) Foo::MEMBER ); // OK       return 0; }
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; }
42535
If I have a class as follows     class Example_Class     {        private:          int x;           int y;         public:           Example_Class()           {               x = 8;              y = 9;          }        ~Example_Class()         { }     };   And a struct as follows  struct {    int x;    int y; } example_struct;   Is the structure in memory of the  example_struct simmilar to that in Example_Class  for example if I do the following  struct example_struct foo_struct; Example_Class foo_class = Example_Class();  memcpy(&amp;foo_struct, &amp;foo_class, sizeof(foo_struct));   will foo_struct.x = 8 and foo_struct.y = 9 (ie: the same values as the x,y values in the foo_class) ?  The reason I ask is I have a C++ library (don't want to change it) that is sharing an object with C code and I want to use a struct to represent the object coming from the C++ library. I'm only interested in the attributes of the object.  I know the ideal situation would be to have Example_class wrap arround a common structure between the C and C++ code but it is not going to be easy to change the C++ library in use.
58422
What are good reasons to prohibit inheritance in Java, for example by using final classes or classes using a single, private parameterless constructor? What are good reasons of making a method final?
35935
I'm using the 'using' declaration in C++ to add std::string and std::vector to the local namespace (to save typing unnecessary 'std::'s).  using std::string; using std::vector;  class Foo { /*...*/ };   What is the scope on this declaration?  If I do this in a header, will it inject these 'using' declarations into every cpp file that includes the header?
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?
45128
Lets say I'm building a base class which will be extended upon by the children class. So a base class is called Base and children can be Child1, Child2, etc.  In the base class's constructor, how can i get the value of Child1/Child2?  This is all using PHP
5040
I'm using an API that requires me to pass a function pointer as a callback. I'm trying to use this API from my class but I'm getting compilation errors.   Here is what I did from my constructor:  m_cRedundencyManager-&gt;Init(this-&gt;RedundencyManagerCallBack);   This doesn't compile - I get the following error:      Error  8 error C3867: 'CLoggersInfra::RedundencyManagerCallBack': function call missing argument list; use '&amp;CLoggersInfra::RedundencyManagerCallBack' to create a pointer to member   I tried the suggestion to use &amp;CLoggersInfra::RedundencyManagerCallBack - didn't work for me.   Any suggestions/explanation for this??  I'm using VS2008.  Thanks!!
17895
In the following snippet:  public class a {     public void otherMethod(){}     public void doStuff(String str, InnerClass b){}     public void method(a){         doStuff("asd",             new InnerClass(){                 public void innerMethod(){                     otherMethod();                 }             }         );     } }   Is there a keyword to refer to the outer class from the inner class?  Basically what I want to do is outer.otherMethod(), or something of the like, but can't seem to find anything.
119176
In some text it is given that we can't assign constant values to a reference variable. When I executed such a program I could do it. Is there any condition we can't assign a constant value to a reference variable?
24549
So I'm refactoring my code to implement more OOP.  I set up a class to hold page attributes.  class PageAtrributes  {   private $db_connection;   private $page_title;      public function __construct($db_connection)      {         $this-&gt;db_connection = $db_connection;         $this-&gt;page_title = '';     }      public function get_page_title()     {         return $this-&gt;page_title;     }      public function set_page_title($page_title)     {         $this-&gt;page_title = $page_title;     } }   Later on I call the set_page_title() function like so  function page_properties($objPortal) {         $objPage-&gt;set_page_title($myrow['title']); }   When I do I receive the error message:     Call to a member function set_page_title() on a non-object   So what am I missing?
86715
I'm looking at some GXT code for GWT and I ran across this use of Generics that I can't find another example of in the Java tutorials. The class name is  if you want to look at all of the code.  Here are the important parts:  private RpcMap map;  public &lt;X&gt; X get(String property) {   if (allowNestedValues &amp;&amp; NestedModelUtil.isNestedProperty(property)) {     return (X)NestedModelUtil.getNestedValue(this, property);   }   return map == null ? null : (X) map.get(property); }   X is defined nowhere else in the class or anywhere in the hierarchy, and when I hit "go to declaration" in eclipse it just goes to the &lt;X&gt; in the public method signature.  I've tried to call this method with the following two examples to see what happens:  public Date getExpiredate() {     return  get("expiredate"); }  public String getSubject() {     return  get("subject"); }   They compile and show no errors or warnings.  I would think at the very least I would have to do a cast to get this to work.  Does this mean that Generics allow a magic return value that can be anything and will just blow up at runtime?  This seems counter to what generics are supposed to do.  Can anyone explain this to me and possibly give me a link to some documentation that explains this a little better?  I've went through Sun's 23 page pdf on generics and every example of a return value is defined either at the class level or is in one of the parameters passed in.
77278
I am calling the method defined in a class implemented from another module using the following code.  use Drupal\module_name\MyClassName;  $instance = Drupal\module_name\MyClassName::getinstance($host, $user, $pass);   My code doesn't work, as I get an error about a class not found. What am I doing wrong?  The class is contained in module/src/controiller/controller_name.php.
111702
Is it possible to assign a base class object to a derived class reference with an explicit typecast in C#?.  I have tried it and it creates a run-time error.
34071
Consider this:  public class TestClass {      private String a;     private String b;      public TestClass()     {     a = "initialized";     }      public void doSomething()     {     String c;          a.notify(); // This is fine     b.notify(); // This is fine - but will end in an exception     c.notify(); // "Local variable c may not have been initialised"     }  }   I don't get it. "b" is never initialized but will give the same run-time error as "c", which is a compile-time error. Why the difference between local variables and members?  Edit: making the members private was my initial intention, and the question still stands...
85865
As just stated in a recent  and , you can't inherit from a static class.  How does one enforce the rules that go along with static classes inside VB.NET?  Since the framework is compatible between C# and VB it would make sense that there would be a way to mark a class static, but there doesn't seem to be a way.
29851
I have an error that seems common on the web,  Though i cant find a definite answer that applies to my case:  I have the following Apex code:  public with sharing class templicenseemail {      private ApexPages.standardController standardController;       public Trainee__c trainee { get; set; }     public templicenseemail(ApexPages.StandardController controller) {         this.standardController = standardController;     }      public PageReference doSomething()     {         trainee  = [SELECT Email__c,First_Name__c,Institution__c,Last_Name__c FROM Trainee__c                  WHERE Id = :ApexPages.currentPage().getParameters().get('id')];                  String whatIs = trainee.Volume_Serial_Number__c;                 integer strlen = whatIs.length();                  ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, trainee.Email__c  ));         return null;      }     }   And the following test case:  @isTest(seealldata=false)      private class Send_noti_emailsTestClass5 {          static testMethod void validateSend_noti_emails5() {              templicenseemail  MyTestcase = new templicenseemail();              // code here in the Middle              MyTestcase.doSomething();          }     }   I'm getting the following error:  Error: Compile Error: Constructor not defined: [templicenseemail].&lt;Constructor&gt;(SOBJECT:Lead) at line:      templicenseemail  MyTestcase = new templicenseemail();   Does anyone know why?