在遵循此 Youtube 教程(请参阅下面的相关代码)时,我收到以下错误:
错误第 6 行
错误:预期的构造函数析构函数或类型转换之前'('
什么可能导致此错误,我该如何解决?
#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <time.h>
void myfun(int);//using own function
myfun(8);//pow(4.0,10.0)
using namespace std;
int main()
{
double num1;
srand(time(0));// to get a true random number
double num2;
num1 = pow(3.0, 9.0);//2 to the power of 4
cout << num1 <<endl;
num2 = rand() %100;//random number out of 100
cout << "\nrandom number = " << num2 << endl ;
return 0;
}
void myfun(int x)
{
using namespace std;
cout << "my favourite number is " << x << endl;
}