C++ 将一个方法的返回值作为参数传递给另一个方法,在一个单独的方法中

C++ 将一个方法的返回值作为参数传递给另一个方法,在一个单独的方法中,c++,methods,C++,Methods,我保证这比听起来要简单。我已经查看了其他帖子,但还没有成功找到任何内容 我有一个方法AList::generateradom(): 以下是其他方法的内容 int ReadRandomAmount(){ int randomAmount; // used to collect the user's input cin >> boolalpha >> randomAmount; while (! cin.good

我保证这比听起来要简单。我已经查看了其他帖子,但还没有成功找到任何内容

我有一个方法
AList::generateradom()

以下是其他方法的内容

int ReadRandomAmount(){
        int randomAmount;        // used to collect the user's input
        cin >> boolalpha >> randomAmount;

        while (! cin.good() || randomAmount < 0 || randomAmount > 50) {

                cin.clear();

                cin.ignore(80, '\n');

               if(!cin.good()){
                  cout << "Invalid data type, should be an element ("
                        << ELEMENT_NAME
                        << "), try again: ";
                  } else
                  cout << "Invalid range type, should be within 0 and 50, try again: ";

                cin >> boolalpha >> randomAmount;
                }

        return randomAmount;
    }

  int ReadRandomLimitLow(){
        int randomLimitLow;        // used to collect the user's input

        cin >> boolalpha >> randomLimitLow;

        while (! cin.good() || randomLimitLow < 0 || randomLimitLow > 2147483646) {

                cin.clear();

                cin.ignore(80, '\n');

               if(!cin.good()){
                  cout << "Invalid data type, should be an element ("
                        << ELEMENT_NAME
                        << "), try again: ";
                  } else
                  cout << "Invalid range type, should be within 0 and 2147483646, try again: ";

                cin >> boolalpha >> randomLimitLow;
                }

        return randomLimitLow;
    }

  int ReadRandomLimitHigh(int randomLimitLow){
        int randomLimitHigh;        // used to collect the user's input

        cin >> boolalpha >> randomLimitHigh;


        while (! cin.good() || randomLimitHigh < randomLimitLow || randomLimitHigh > 2147483647) {


                cin.clear();


                cin.ignore(80, '\n');


               if(!cin.good()){
                  cout << "Invalid data type, should be an element ("
                        << ELEMENT_NAME
                        << "), try again: ";
                  } else
                  cout << "Invalid range type, should be within " << randomLimitLow << " and 2147483647, try again: ";

                cin >> boolalpha >> randomLimitHigh;
                }

        return randomLimitHigh;
    }
int ReadRandomAmount(){
int randomAmount;//用于收集用户的输入
cin>>boolalpha>>随机数量;
而(!cin.good()| | randomAmount<0 | | randomAmount>50){
cin.clear();
cin.忽略(80,“\n”);
如果(!cin.good()){
不能随机化;
}
返还金额;
}
int ReadRandomLimitLow(){
int randomLimitLow;//用于收集用户的输入
cin>>boolalpha>>randomLimitLow;
而(!cin.good()| | randomLimitLow<0 | | randomLimitLow>2147483646){
cin.clear();
cin.忽略(80,“\n”);
如果(!cin.good()){
cout-limitlow;
}
回报率低;
}
int ReadRandomLimitHigh(int randomLimitLow){
int randomLimitHigh;//用于收集用户的输入
cin>>布拉尔法>>高;
而(!cin.good()| | randomLimitHigh2147483647){
cin.clear();
cin.忽略(80,“\n”);
如果(!cin.good()){

至少在你发布的代码中,
randomLimitLow
从未声明过。将其声明为
int
是否有帮助?步骤1:不要使用
srand
/
rand
-你会得到非常糟糕的随机数。请参阅和。你声明了
ReadRandomAmount()
AList
类定义中?您似乎将其作为一个全局函数。我没有发布定义,但它们都在那里,在我尝试将ReadRandomLimitLow的返回值包含为参数之前,它们都工作得很好。我的水晶球告诉我,您已经定义了一个全局
ReadRandomAmount
函数,nt
AList::ReadRandomAmount
成员函数。但在过去400年左右的时间里,它一直存在接收问题。
Undefined symbols for architecture x86_64:
  "AList::ReadRandomAmount()", referenced from:
      AList::GenerateRandom() in AList-2fa708.o
  "AList::ReadRandomLimitLow()", referenced from:
      AList::GenerateRandom() in AList-2fa708.o
ld: symbol(s) not found for architecture x86_64
int ReadRandomAmount(){
        int randomAmount;        // used to collect the user's input
        cin >> boolalpha >> randomAmount;

        while (! cin.good() || randomAmount < 0 || randomAmount > 50) {

                cin.clear();

                cin.ignore(80, '\n');

               if(!cin.good()){
                  cout << "Invalid data type, should be an element ("
                        << ELEMENT_NAME
                        << "), try again: ";
                  } else
                  cout << "Invalid range type, should be within 0 and 50, try again: ";

                cin >> boolalpha >> randomAmount;
                }

        return randomAmount;
    }

  int ReadRandomLimitLow(){
        int randomLimitLow;        // used to collect the user's input

        cin >> boolalpha >> randomLimitLow;

        while (! cin.good() || randomLimitLow < 0 || randomLimitLow > 2147483646) {

                cin.clear();

                cin.ignore(80, '\n');

               if(!cin.good()){
                  cout << "Invalid data type, should be an element ("
                        << ELEMENT_NAME
                        << "), try again: ";
                  } else
                  cout << "Invalid range type, should be within 0 and 2147483646, try again: ";

                cin >> boolalpha >> randomLimitLow;
                }

        return randomLimitLow;
    }

  int ReadRandomLimitHigh(int randomLimitLow){
        int randomLimitHigh;        // used to collect the user's input

        cin >> boolalpha >> randomLimitHigh;


        while (! cin.good() || randomLimitHigh < randomLimitLow || randomLimitHigh > 2147483647) {


                cin.clear();


                cin.ignore(80, '\n');


               if(!cin.good()){
                  cout << "Invalid data type, should be an element ("
                        << ELEMENT_NAME
                        << "), try again: ";
                  } else
                  cout << "Invalid range type, should be within " << randomLimitLow << " and 2147483647, try again: ";

                cin >> boolalpha >> randomLimitHigh;
                }

        return randomLimitHigh;
    }