gpt4 book ai didi

c++ - 请求从 `double' 到非标量类型的转换和一些其他错误

转载 作者:太空宇宙 更新时间:2023-11-03 10:20:22 25 4
gpt4 key购买 nike

<分区>

请阅读我的代码,并帮助我调试它。因为 Dev-C++ 发现了很多错误....

#include<iostream.h>
#include<conio.h>
using namespace std;

struct iWorker{
double salary;
}

double calSalary(iWorker worker){
double money = worker.salary;
return money;
}

int main(){
iWorker worker;

cout << "Enter salary: ";
cin >> worker.salary;

double salary = calSalary(worker, 0);
cout << salary;

getch();
return 0;
}

和错误:

9: error: new types may not be defined in a return type
9: error: two or more data types in declaration of `calSalary'
In function `iWorker calSalary(iWorker)':
11: error: conversion from `double' to non-scalar type `iWorker' requested

In function `int main()':
9: error: too many arguments to function `iWorker calSalary(iWorker)'
20: error: at this point in file
20: error: cannot convert `iWorker' to `double' in initialization

谢谢...

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