来自' int(*)(int)'的转换无效到' int' [-fpermissive]

时间:2015-07-24 22:22:49

标签: c++

我之前已经知道这个错误,但我无法理解其他答案。这是我的代码:

    #include <iostream>

using namespace std;

int processDate (int day){
 if (day <= 6){
     return day;
 }else{
   day -= 7;
   return processDate(day);
 }
}

int calculateYear (int year){
    return year;
}

int main(){
 int monthCode [] = {6,2,2,5,0,3,5,1,4,6,2,4};
 string dayName [] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Sunday"};
 int d,m,y = 0;
 int dayNum;
 cin >> d >> m >> y;
 dayNum = d + monthCode[m] + calculateYear[y];
 cout << dayName[processDate(dayNum)];
}

calculateYear()和processDate()是当时空的2个函数。我只是测试基本代码编译。错误发生在&#34; dayNum = ...&#34;在第二个&#34; +&#34;之前。提前谢谢!

2 个答案:

答案 0 :(得分:2)

calculateYear(y)括号不是方括号。

答案 1 :(得分:0)

错误说某处有指向函数指针的int的赋值。指向函数返回int并将int作为参数。寻找这样的东西:

int myfunc (int);

int x = myfunc;