The following piece of code gets compiled under g++ 4.6.3 for Linux
#include <iostream>
class A {
  public:  
    int x;
    std::string c;
    A(int x,std::string c):x(10),c("Hi"){
    }
    ~A(){
      std::cout << "Deleting A()" << std::endl;
    }
};
class B : public A {
  public:
    B():A(20,"Hello"){
    }
    ~B(){
      std::cout << "Deleting B()" << std::endl;
    }
};
int main(){
  B o;
  std::cout << o.x << std::endl;
  std::cout << o.c << std::endl;
  return(0);
}
but it does not do what is supposed to do, the type B is not able to change the values of that 2 variables that it inherit from A.
Any explanations about why this doesn't work properly ?
 
     
     
     
    