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

Derivatives stock list at NSE

Complete FNO stock list at NSE. ABB India Ltd ACC Ltd APL Apollo Tubes Ltd AU Small Finance Bank Ltd Aarti Industries Ltd Abbott India Ltd A...