-3
我尝试使用向量惠特指针和模块。 我有这个问题与C++: 在main.cpp中:错误无效类型参数的一元'*'(有'int')与模块
#include<iostream>
using namespace std;
#include "Funcion1.hpp"
int main (int argc, char *argv[]) {
int vec[20];
int *punteroV = &vec[0];
for(int i = 0;i < 10;i++){
cout<<"Ingrese numero: ";
cin>>vec[i];
}
cout<<FUN(*punteroV) << endl;
return 0;
}
和模块中:
#include "Funcion1.hpp"
#include<iostream>
using namespace std;
int FUN(int &punteroV){
int num;
for(int i = 0;i<10;i++){
for(int j = 0;j<10;j++){
cout<<"i: "<<(punteroV+ i)<<endl<<"j: "<<(punteroV + j)<<endl;
if(*(punteroV + i) > *(punteroV + j)){
num = (punteroV + i);
}
}
}
return num;
}
和.HPP
#ifndef FUNCION1_H
#define FUNCION1_H
int FUN(int&);
#endif
编译器产生错误的模块中:
error invalid type argument of unary '*' (have 'int')
这个错误的含义是什么?
这意味着'punterOv + i'是'int',而不是指针。 –
[错误:一元'\ *'(有'int')]的无效类型参数可能的重复(https://stackoverflow.com/questions/33521200/error-invalid-type-argument-of-unary-have- int) – melpomene
是int'* punteroV =&vec [0];' –