Basic C++ Challenge - Int-Cognito :)

AceInfinity

Emeritus, Contributor
Joined
Feb 21, 2012
Posts
1,728
Location
Canada
Fancy title :lolg:

The task is to create an implementation of the class I gave an outline of in the following code:
Code:
[NO-PARSE]#include <iostream>
#include <vector>
#include <algorithm>

template <typename T>
class _BaseInt
{
	// Your implementation here
};

int main(void)
{
	const unsigned max = 5;
	unsigned n = 10;
	_BaseInt<unsigned> m(&n);
	std::vector<_BaseInt<unsigned>> v;

	std::fill_n(std::back_inserter(v), max + 1, m);
	std::fill_n(std::back_inserter(v), max, m);

	std::copy(v.begin(), v.end(), std::ostream_iterator<unsigned>(std::cout, " "));
	std::endl(std::cout);
	return 0;
}[/NO-PARSE]

Such that you get the expected output of: 10 11 12 13 14 15 16 17 18 19 20

Rules:
- You can't modify anything inside the main function.
- All you can do is work within the boundaries of the _BaseInt class to make sure that it provides the functionality needed to get the expected output.

For those of you who want to see the solution, see the following:
*SPOILER* - If you are trying this challenge, do not peek until you've given up or came up with a solution of your own.
Read More:

Good luck :thumbsup2:
 
I'd look more at them, but I haven't done any programming in a while. Getting a bit busy lately.

Writhziden is still around, but he has a lot of other commitments.
 

Has Sysnative Forums helped you? Please consider donating to help us support the site!

Back
Top