Question: What is output? #include using namespace std; class School { public: School ( ) ; static int getNextId ( ) ; private: int id =

What is output?
#include
using namespace std;
class School {
public:
School();
static int getNextId();
private:
int id =0;
static int nextId;
};
School::School(){
id = nextId;
nextId +=1;
}
int School::getNextId(){
return nextId;
}
int School::nextId =0;
int main(){
School();
cout << School::getNextId()<<"";
School();
cout << School::getNextId()<<"";
School();
cout << School::getNextId()<<"";
School();
cout << School::getNextId()<<"";
}
Group of answer choices
3210
0123
4321
1234

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!