- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在尝试修复这段代码,但我总是遇到同样的错误。我不确定如何修复,我希望这里有人可以解决。编译器消息是:
no matching function for call to `Date::Date(int)'
note candidates are: Date::Date(const Date&)
note Date::Date(int, int, int)
note Date::Date()
这是主要文件:
/*-------------------- Lab7.cpp ------------------*/
#include <iostream>
#include <iomanip>
#include "Employee.h"
using namespace std;
int main ( )
{
Employee emp1;
emp1.printPInfo( );
Employee emp2("John", "Doe", 111111, Date((10,25,1990)),
Date((11, 15, 2010)), 750.00);
emp2.printPInfo( );
Employee emp3;
emp3.readPInfo( );
emp3.printPInfo( );
Employee emp4("Peter", "Parker", 222222, Date((8, 12, 1985)),
Date((11, 32, 2114)), 800.00);
return 0;
}
这是包含在主文件中的 Employee.h 文件:
/*-------------------- Employee.h ---------------*/
#include <string>
#include "Date.h"
using std::string;
class Employee
{
public:
Employee( );
Employee(string fName, string lName, int id,
Date &bday, Date &hday, double bpay);
void readPInfo( );
void readPayInfo( );
void printPInfo( );
double getBpay( );
double getGpay( );
double computeTax( );
void printPayInfo( );
private:
string firstName, lastName;
int idNum;
Date birthDay;
Date dateHired;
double basePay;
};
最后是 Employee.h 中包含的 Date.h 文件
/*-------------------- Date.h --------------------*/
#ifndef DATE_H
#define DATE_H
class Date
{
public:
Date(int m = 1, int d = 1, int y = 1);
void inputDate( );
void outputDate( );
int getMonth( ), getDay( ), getYear( );
private:
int month, day, year;
void checkDate( );
};
#endif
最后,这里是上面头文件的两个cpp文件:
/*------------------- Date.cpp -------------------------*/
#include <iostream>
#include <cstdlib>
#include "Date.h"
using namespace std;
Date:: Date( int m, int d, int y)
{
month = m;
day = d;
year = y;
checkDate( );
}
void Date:: checkDate( )
{
int m, d, y;
m = getMonth( );
d = getDay( );
y = getYear( );
static int daysofmonth[12]= {31, 28, 30, 31,
30, 31, 30, 31,
30, 31, 30, 31};
if ( m < 1 || m >12)
cout << "\nInvalid Month.";
exit(1);
if (d < 1 || d > daysofmonth[m - 1])
cout << "\nInvalid Day.";
exit(2);
if (y < 1960 || y > 2013)
cout << "\nInvalid Year.";
exit(3);
}
void Date:: inputDate( )
{
cin >> month >> day >> year;
checkDate( );
}
void Date:: outputDate( )
{
cout << getMonth( ) << "/"
<< getDay( ) << "/" << getYear( );
}
int Date:: getMonth( )
{
return (month);
}
int Date:: getDay( )
{
return (day);
}
int Date:: getYear( )
{
return (year);
}
/*------------------ Employee.cpp ---------------*/
#include <iostream>
#include <iomanip>
#include "Employee.h"
using namespace std;
/*----------------- constructors ----------------*/
Employee ::Employee( ): idNum(999999),
dateHired(Date(1, 1, 2013))
{
basePay = 0.00;
}
Employee ::Employee(string fname, string lname,
int id, Date &bday, Date &hday, double bpay)
{
firstName = fname;
lastName = lname;
idNum = id;
birthDay = bday;
dateHired = hday;
basePay = bpay;
}
/*-------------- Member Functions ---------------*/
void Employee :: readPInfo( )
{
cin >> firstName >> lastName >> idNum;
birthDay.inputDate( );
dateHired.inputDate( );
}
void Employee :: readPayInfo( )
{
cin >> basePay;
}
void Employee :: printPInfo( )
{
cout << setw(10) << "Name:\t" << lastName
<< ", " << firstName << endl;
cout << setw(10) << "ID:\t" << idNum << endl;
cout << setw(10) << "DOB:\t";
birthDay.outputDate( );
cout << endl << setw(10) << "BOH:\t";
dateHired.outputDate( );
cout << endl;
}
double Employee :: getBpay( )
{
return(basePay);
}
double Employee :: computeTax( )
{
double taxDeduct, gross;
gross = getGpay( );
if(gross > 1000) taxDeduct = gross * .20;
else if(gross >= 800) taxDeduct = gross * .18;
else if(gross >= 600) taxDeduct = gross * .15;
else taxDeduct = gross *.10;
return(taxDeduct);
}
void Employee :: printPayInfo( )
{
double gross, tax;
gross = getGpay( );
tax = computeTax( );
cout << "\nTax Deduction:\t$" << tax;
cout << "\nNetPay:\t$" << gross - tax;
}
错误指向两行:
Employee emp2("John", "Doe", 111111, (Date(10,25,1990)),(Date(11, 15, 2010)), 750.00);
Employee emp4("Peter", "Parker", 222222, (Date(8, 12, 1985)),(Date(11, 32, 2114)), 800.00);
有什么问题吗?
最佳答案
喜欢的电话
Date((11, 15, 2010))
可能是罪魁祸首。内部括号使它传递一个参数,而不是将三个整数传递给日期构造函数,该参数的值是表达式 11, 15, 2010
的值。逗号被解释为逗号运算符,它计算第一个和第二个操作数,丢弃第一个的值,并返回第二个。
使用 Date(11, 15, 2010)
应该没问题。
编辑:请注意,如果您要传递一个临时变量,您的 Employee
构造函数必须通过 const
引用来获取它们(无论如何它应该是因为它只是存储一个拷贝而不是以任何方式修改 Date
对象)。
关于c++ - 错误 : no matching function for call to/candidates are,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23356561/
我正在尝试为匹配中的每个匹配呈现一些 HTML,但是,我不太确定 实际上是正确的。 更具体地说,我不确定我是否可以使用 v-bind:match='match'在与循环相同的元素上 v-for='ma
它具有看似简单的代码: method match(Any:U: |) { self.Str; nqp::getlexcaller('$/') = Nil } 但是,这是它的行为: (^3).matc
如果您想检查某项是否与正则表达式匹配,如果是,请打印第一组,您就可以了.. import re match = re.match("(\d+)g", "123g") if match is not N
以下两个查询的结果有差异吗? SELECT * FROM table1, table2 WHERE ( MATCH(table1.row1) AGAINST('searchstring' IN
我正在尝试为我的日志文件创建一个语法文件。它们采用以下格式: [time] LEVEL filepath:line - message 我的语法文件如下所示: :syn region logTime
String#match 和 Regexp#match 在匹配成功时返回一个 MatchData: "".match(//) # => # //.match("") # => # //.match(:
我的代码中有这个函数: func match(match: GKMatch, player playerID: String, didChangeState state: GKPlayerConnec
我对 match 和 case 之间的区别感到困惑。在 document ,其中提到match支持通用模式匹配。 > (define (m x) (match x [(list a
我在检查特定元素中的空 HTML 内容时遇到了问题。当我使用 someElement.trim().match("") 即使 HTML 内容为空,我有时也会得到 true。我改成了 someEleme
我正在尝试使用正则表达式查找包含特定词的两个词之间的所有内容,但是这些词是重复的,所以我没有得到我想要的匹配项。 例如,我想要“你好”和“再见”之间的所有内容,以便它们之间存在“苹果”一词: hell
我目前正在构建一个 PHP 脚本,它将在需要时响应 HTTP“304 Not Modified”。 (请参阅 question #2086712 了解我目前所做的事情)。 目前我回答以下问题: If-
给定以下 XML 10 我希望能够正确识别内部 的 s : result = subject.gsub(/]*>)/, '<') 解释: ]* # any number of charact
这个问题在这里已经有了答案: How to error handle 1004 Error with WorksheetFunction.VLookup? (3 个回答) 3年前关闭。 目标:查找输入
我已经尝试了好一阵子了,但是我似乎无法弄清楚这两者之间的区别。特别是,与数据数组有关的差异: PS C:>$myarray = "a", "ab", "abc" PS C:>$myarray -mat
我正在努力研究如何构建一个宏,让我可以将模式和结果以向量的形式传递给 core.match/match 。我希望能够做到这一点: (let [x {:a 1} patterns [[{:a
这个问题在这里已经有了答案: Reference - What does this regex mean? (1 个回答) 关闭 8 年前。 如果这看起来微不足道但只是为了理解正则表达式,请原谅我:
我的 MySQL 表中有大约 20 行,其 Title 列为 Elsewhere 并具有其他不同的列参数。 我目前正在使用这样的查询,因为我的大多数搜索(通过 PHP 文件)都需要我进行猜测。所以我使
当找到匹配时,我必须从字符串中删除单词 让我们看看 我的输入字符串是 “肯诺克斯路” 比赛表演中的单词表 街道 驾驶 道路 4. 车道 输出字符串应该是: KENOX 我正在使用 vb.net 作为此
我正在搜索以下形式的字符串模式: XXXAXXX # exactly 3 Xs, followed by a non-X, followed by 3Xs 所有的 X 必须是相同的字符,并且 A 不能
好吧,我是 gulp 和 sass 的新手,我正在努力让它发挥作用。我正确安装了所有东西,但我收到了这个愚蠢的错误。有解决办法吗? PS C:\Users\Bojan Kolano\Desktop\F
我是一名优秀的程序员,十分优秀!