Warning: Trying to access array offset on false in /home3/indiakep/public_html/wp-content/plugins/dw-question-answer/inc/Template.php on line 8
2 Answers
Code:
#include <iostream>
using namespace std;
class Base
{
public:
int x;
static int y;
};
int Base::y;
int main()
{
Base b1;
b1.x = 10;
b1.y =30;
Base b2;
b2.x =20;
b2.y =40;
cout<<b1.x<<endl;
cout<<b1.y<<endl;
cout<<b2.x<<endl;
cout<<b2.y<<endl;
return 0;
}
Output:
10
40
20
40
