728x90 AdSpace

Latest Article



using class C++ example with code and solution





using class C++ programming language  example with code and solution 

1. What will be the output of this code?

class blah {
public:
  static int a; 
  int b;
  blah(int x) {
    b=x;
    a=b+1;
  }

};
int blah::a = 0;
int main(void) {

  blah b1(5);
  blah b2(12);
  cout << "b1.a is " << b1.a << endl;
  cout << "b1.b is " << b1.b << endl;
  cout << "b2.a is " << b2.a << endl;
  cout << "b2.b is " << b2.b << endl;
}



b1.a is 13
b1.b is 12
b2.a is 13
b2.b is 12

 
 




no image






  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment