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

5 May 2024 Hari Om Verse 50-51, chapter two:  In this chapter two Shree krishna explains a simple way of living. Free from desires and void ...