A C++ object is an instantiation of a class that can contain both ____ and ____
answers:
i. variable
ii. data members
iii. methods
iv. field
1) All of the above
2) i & iv only
3) ii & iii only
4) None of the above
My answer is 3(data members & methods) Am I correct?
Question 3.
class B
{
private:
static int b;
public:
B()
{
b = 2;
}
void setB(int b)
{
this ->b = b;
}
int getB()
{
return b;
}
};
int main()
{
B theB;
theB.setB(4);
cout << theB.getB() << endl;
}
answers:
1) The output is 2
2) The output is 4
3) The instance member function can access the static data member, b
4) The static data member needs to be declared at the implementation section
Please don't ask us to correct our homework, that could be considered as cheating.
That being said, I suggest you read some of the links on this page: https://www.google.com/search?q=c%2B%2B%20static%20data%20member