Better Random Number

Oct 6, 2017 at 6:01am
Bear with me here guys as I am dumping a lot of codes. Hopefully you guys are feeling generous and check it out to help a brother out. Any help would be greatly appreciated!
Last edited on Oct 9, 2017 at 5:49pm
Oct 6, 2017 at 6:38am
What's wrong with C++'s <random>? Simple C rand is a pretty weak rng, even if you juggle it a little.

About your error, it is pretty self explanatory, you need to define a conversion operator for your custom Double to POD double.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <string>

struct String
{
   std::string str;

   operator float() const
	{
	    return std::stof(str);
	}
};

int main()
{
	String s{ "1010" };
	float no = s;
	std::cout << no;

	return 0;
}


Outputs
1010
Last edited on Oct 6, 2017 at 6:39am
Oct 6, 2017 at 6:46pm
Okay, forget the error I was having trouble with. I think I fixed it.
As of now I have another problem.
Last edited on Oct 9, 2017 at 5:50pm
Oct 7, 2017 at 5:53pm
I'm afraid we need a compilable or nearly compilable code to help you. It's really hard to guess all the missing part.
Oct 7, 2017 at 6:37pm
Sorry about that. I'm gonna edit it so it compiles. Thanks for pointing that out.
Topic archived. No new replies allowed.