Sunday, February 25, 2018

C++ program : IDGenerator

#include<iostream>
using namespace std ;
class IDGenerator {
private:
static int s_nextID;
public:
static int getNextID(); // Fill in the keyword
};
int IDGenerator::s_nextID=0;// Fill in the statement
int IDGenerator::getNextID() { return s_nextID++; }
int main() {
int add = 0, count = 0;
cin >> count;
for (int i = 0; i < count; ++i){
add = add + IDGenerator::getNextID();
}
cout << add;
return 0;
}

Thanks
Happy Computing !

No comments:

Post a Comment

Sacred Thought

28 April 2024 Today I am going to explain verse 31 - 38 chapter two for you all. There is no opportunity better than a righteous war (सत्य औ...