Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7441171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:58:06+00:00 2026-05-29T10:58:06+00:00

First, I’m not realy having a problem, but I like to keep things as

  • 0

First, I’m not realy having a problem, but I like to keep things as simple as possible.
I’m using a templated class named Math and besides a lot of other stuff there are random functions.

Different types of random functions, and a function to set the random seed. So every function except the seed function uses the type class Real. But when I want to set the seed I have to pass some random (haha) type to be able to call the function:

Math<u32>::SeedRandom(System::time());

Again this is not a real problem, but I’m curious if it’s possible to get the same result without the need to use the <u32>.

Here a snippet from the Math class:

template <class Real>
class Math
{
public:
    static void SeedRandom(u32 seed) { srand(seed); }
    static Real UnitRandom() { return (Real)((f64)rand() / (f64)RAND_MAX); }
};

btw. f64 is typedef’d to double and u32 to unsigned int.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:58:07+00:00Added an answer on May 29, 2026 at 10:58 am

    Static functions should be called by ClassName::FunctionName. Because ClassName is a template, you have to specify template arguments. Static functions can also be called on an object, i.e. object.StaticFunctionName, so if you have an object already, you can avoid specifying template arguments, but in my personal biased opinion calling a static function on an object is ugly.

    What I’d do if I were you is to make the function a nonmember one (friend to the template, if needed), in the same namespace as your class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, let's get the security considerations out of the way. I'm using simple authentication
We're building an app, our first using Rails 3, and we're having to build
First off, I'm not all that familiar with cookies but I know how they
First of all, i would like to explain my condition right now. I'm using
I'm making a simple page using Google Maps API 3. My first. One marker
first I 'm trying to install rrdtool using: yum install rrdtool but failed: no
First off, I am using Windows XP. I have multiple hard drives and it
First off, I understand the reasons why an interface or abstract class (in the
First of all, I know how to build a Java application. But I have
First off: I'm using a rather obscure implementation of javascript embedded as a scripting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.