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 8357677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:33:28+00:00 2026-06-09T10:33:28+00:00

I want to call ‘int Random::random(int lower, int upper) function, however I get a

  • 0

I want to call ‘int Random::random(int lower, int upper) function, however I get a problem saying ‘member function may not be re-declared outside of it class’ also I tried to provide a solution in the form of the following:

‘Random m;
m.Random()’

which say the following problem ‘too few argument in function call’

Below is the main.cpp file

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

#include "Circle.h"
#include "Random.h"

int main()
{
    Random m;
    m.random();

    // Array 1, below section is to populate the array with random 
    // radius number within lower and upper range
    int CircleArrayOne [5];
    const int NUM = 5;

    srand(time(NULL));

    for(int x = 0; x < NUM; ++x)
    {
        int Random::random(int lower, int upper);
    }

    // output the radius of each circle
    cout << "Below is the radius each of the five circles in the second array. " << endl;

    // below is to output the radius in the array
    for(int i = 0; i < NUM; ++i) 
    {
        cout << CircleArrayOne[i] << endl;
    }

    system("PAUSE");
    return 0;
}


int Random::random(int lower, int upper)
{
    cout << "Enter lower number: " << lower << endl;
    cout << "Enter upper number: " << upper << endl;

    int range = upper - lower + 1;
    return (rand() % range + lower);
}

Below is the Random.h file

#pragma once
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

class Random
{
public:
    static void initialiseSeed();
    // random number initialised
    // random number has been initialised to the current time.

    static int random(int lower, int upper);
    // this function will return a positive random number within a specific lower and 
    // upper boundary.
};

Can you help with where I’m going wrong please.
All help is much appreciated

  • 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-06-09T10:33:30+00:00Added an answer on June 9, 2026 at 10:33 am

    There are two issues here.

    First, you call m.random() — no such function exists. You need to give it two int arguments. Also, since it’s static, you don’t need Random m at all; you can just use Random::random(some_int, some_other_int);.

    Secondly, you have this:

    for(int x = 0; x < NUM; ++x)
    {
        int Random::random(int lower, int upper);
    }
    

    There are actually two problems here: first, this is not a function call, it’s a function declaraction. Function declarations are of the form return_type function_name(arg_type arg_name /* etc. */); as you have here. To call it, you need to just pass actual values to it, and not include the return value — that’s what it will give you.

    Secondly, you need to actually store the result somewhere. Your comments indicate that this is supposed to be CircleArrayOne, but you don’t actually populate it as you claim to.

    Try this:

    for(int x = 0; x < NUM; ++x)
    {
        CircleArrayOne[x] = Random::random(0, 10); // assumed 0 and 10 as the bounds since you didn't specify anywhere; you could use variables here also
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to call a function a number of times providing it with different
I want to call a function which is in another php class that I
I want to call a website using PL/SQL and get the return value of
I want to call a function printPager($max_pages,$pg); to show up after the last value
I want call a url and get the response data from the url from
I want call OnClick function on page load with out user clicking. Can we
I want to call some function repeatly in client's browser. System::Timers::Timer work only on
I want to call a function low_level_init which has signature void low_level_init(struct netif *netif)
Hi I want call f('append','more','arguments',a=1,b=2) but append is a method(function) of pyquery module so
I want to call an https url from java and it is not trusted,

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.