C ++警告和错误功能 [英] C++ warning and error function
问题描述
#include <iostream>
#include <conio.h>
#include <string>
#include <iomanip>
using namespace std;
class payroll {
private:
string name;
int days_work;
float rate;
float pay;
float sss;
float phil;
float deduct;
float totalpay;
public :
int get_info();
void display_info();
};
////////////////////////////////////////////////////////////////////
const int PASSLEN = 4;
string passget();
void start()
{
string password;
cout << "\n\n";
cout << "\t SECURITY FORM";
cout << "\n\n";
cout << "Enter Your Password: ";
password = passget();
if (password == "bscs") {
cout << "\n\n";
cout << "Password Accepted";
cout << "\n\n\n";
payroll emp;
emp.get_info();
emp.display_info();
}
else {
cout << "\n\n";
cout << "Password Denied Try Again !!!";
start();
}
} // End of Start Function
int main()
{
start();
getch();
}
string passget()
{
char password[PASSLEN], letter;
int loop;
int len;
string password2;
//Get Password and replace letters with *--------------
loop = 0;
while(loop != PASSLEN)
{
password[loop] = '\0';
loop++;
}
loop = 0;
len = 0;
letter = '\0';
while( letter != '\r' )
{
letter = getch();
if( letter == '\b' && password[0] == '\0')
{
loop = 0;
len = 0;
}
else
{
if( letter == '\b' && password[0] != '\0')
{
cout << "\b";
cout << " ";
cout << "\b";
loop--;
password[loop] = '\0';
len--;
}
else
{
if( isprint( letter ) != 0 && loop < PASSLEN)
{
password[loop] = tolower(letter);
cout << "*" ;
}
loop++;
if (loop <= PASSLEN)
len++;
}
}
}
//Convert Password from character array to string
loop = 0;
len = len;
password2 = "";
while (loop != len)
{
password2 = password2+password[loop];
loop++;
}
return password2;
} // End of Function Password
/////////////////////////////////////////////////////////////////////
int payroll :: get_info()
{
cout << "\t\t Welcome to Payroll System";
cout << "\n\n";
cout << "Enter Employees Name : ";
getline(cin,name);
cout << "Enter No. of Days Worked : ";
cin >> days_work;
cout << "Enter Daily Rate : ";
cin >> rate;
cout << "Enter SSS or GSIS : ";
cin >> sss;
cout << "Enter Philhealth : ";
cin >> phil;
cout << fixed << setprecision(4);
pay = (days_work * rate);
deduct = (sss + phil);
totalpay= (pay - deduct);
}
void payroll ::display_info()
{
cout << "\n\n";
cout << "*****@@---DETAILED REPORT---@@*****";
cout << "\n\n";
cout << "\nEmployees Name : " << name;
cout << "\n\n";
cout << "\nEmployees Salay is : $" << pay;
cout << "\n\n";
cout << "\nEmployees SSS deduction is : $" << sss;
cout << "\n\n";
cout << "\nEmployees Philhealt deduction is : $" << phil;
cout << "\n\n";
cout << "\nEmployees Total deduction is : $" << deduct;
cout << "\n\n";
cout << "\n\n";
cout << "\n\n";
cout << "\nEmployees Total Salary is : $" << totalpay;
cout << "\n\n";
system("pause");
}
////////////////////////////////////////////////
美好的一天..我需要一些与此C ++代码有关的帮助,因为这些错误是:
C:\ Program Files \ Microsoft Visual Studio \ MyProjects \ payroll daw \ payroll nga daw.cpp(64):警告C4508:"main":函数应返回值;假定为"void"返回类型
和
C:\ Program Files \ Microsoft Visual Studio \ MyProjects \ payroll daw \ payroll nga daw.cpp(149):错误C4716:``payroll :: get_info'':必须返回一个值
任何愿意帮助的人..
非常感谢..
good day.. I need some help regarding this code for C++ because the errors are:
C:\Program Files\Microsoft Visual Studio\MyProjects\payroll daw\payroll nga daw.cpp(64) : warning C4508: ''main'' : function should return a value; ''void'' return type assumed
and
C:\Program Files\Microsoft Visual Studio\MyProjects\payroll daw\payroll nga daw.cpp(149) : error C4716: ''payroll::get_info'' : must return a value
any one there who is willing to help..
Big Thanks..
推荐答案
"<< pay; cout<< " ; cout<< "
" << pay; cout << "\n\n"; cout << "\nEmployees SSS deduction is :
" << ; sss; cout<< " ; cout<< "
" << sss; cout << "\n\n"; cout << "\nEmployees Philhealt deduction is :
" << ;菲尔 cout<< " ; cout<< "
" << phil; cout << "\n\n"; cout << "\nEmployees Total deduction is :
这篇关于C ++警告和错误功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!