注册 登录
编程论坛 C++教室

c++提示错误:'plural' followed by 'int' is illegal (did you forget a ';'?)

anglebaby 发布于 2013-11-02 10:24, 1039 次点击
#include<iostream>
using namespace std;
#include "function.h"

int main()
{
    plural f(4.5);   
    plural x(2.1,3.2);
    float a=2.3;
    f.add(x);
    f.printf();
    f.add(a);
    f.printf();
    f.subtract(x);
    f.printf();
    f.multiply(x);
    f.printf();
    return 0;
}
plural 是复数类
提示的错误:
function.cpp
C:\Users\qq\Desktop\function.cpp(5) : error C2628: 'plural' followed by 'int' is illegal (did you forget a ';'?)
C:\Users\qq\Desktop\function.cpp(8) : warning C4305: 'argument' : truncation from 'const double' to 'const float'
C:\Users\qq\Desktop\function.cpp(8) : warning C4305: 'argument' : truncation from 'const double' to 'const float'
C:\Users\qq\Desktop\function.cpp(9) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
执行 cl.exe 时出错.
4 回复
#2
wp2319572013-11-02 10:31
#include "function.h"

#3
rjsp2013-11-02 10:41
既然是 function.cpp 编译报错,你不贴function.cpp的内容???
#4
xiaodu0002013-11-03 06:08
把using namespace std;放在第三行试试
#5
peach54602013-11-03 09:34
以下是引用rjsp在2013-11-2 10:41:58的发言:

既然是 function.cpp 编译报错,你不贴function.cpp的内容???

+1
1