gpt4 book ai didi

c++ - 从 int 到 int 的无效转换

转载 作者:行者123 更新时间:2023-11-27 23:33:30 25 4
gpt4 key购买 nike

#include <iostream>

#include<fstream>
using namespace std;

void showvalues(int,int,int []);
void showvalues2(int,int);
void sumtotal(int,int);
int main()
{

const int SIZE_A= 9;
int arreglo[SIZE_A];


ifstream archivo_de_entrada;
archivo_de_entrada.open("numeros.txt");


int count,suma,total,a,b,c,d,e,f;
int total1=0;
int total2=0;

//lee///
for(count =0 ;count < SIZE_A;count++)
archivo_de_entrada>>arreglo[count] ;
archivo_de_entrada.close();


showvalues(0,3,9); HERE IS THE PROBLEM
showvalues2(5,8);
sumtotal(total1,total2);

system("pause");
return 0;
}

void showvalues(int a,int b,int v)
{
//muestra////////////////////////
cout<< "los num son ";
for(count = a ;count <= b;count++)
total1 = total1 + arreglo[count];
cout <<total1<<" ";
cout <<endl;
}
void showvalues2(int c,int d)
{
//////////////////////////////
cout<< "los num 2 son ";
for(count =5 ;count <=8;count++)
total2 = total2 + arreglo[count];
cout <<total2<<" ";
cout <<endl;
}

void sumtotal(int e,int f)
{
/////////////////////////////////
cout<<"la suma de t1 y t2 es ";
total= total1 + total2;
cout<<total;
cout <<endl;

}

最佳答案

showvalues 需要一个 int array 作为它的第三个参数 - 你正试图传递一个 int。

您需要修复原型(prototype),使其与实际定义匹配,即更改:

void showvalues(int,int,int []);

到:

void showvalues(int,int,int);

关于c++ - 从 int 到 int 的无效转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3028058/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com