Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
终端错误MacOS:/Applications/Xcode.app/Contents/Developer/Toolchains/xcodefault.xctoolchain/usr/include/c++/v1/istream:1634:1:注意: 当我尝试运行C++程序时,会产生错误: #include <iostream> #include <ctime> //standard c++ library of time.h using namespace std; class DateCplusplus{ private: int _day, _month, _year; //define variable public: void readValues(){ cout<<"Enter the day value: "; cin>>_day; cout<<"\nEnter the month value: "; cin>>_month; cout>>_year; _year = _year - 1900; } int verifyValues(){ if(_day>=1 && _day <=31 && _month>=1 && _month<= 12){ return 1; } return 0; } int compareValues(){ time_t now = time(0); tm *ltm = localtime(&now); if((_year == ltm -> tm_year) && (_month ==1 +ltm -> tm_mon) && (_day == ltm -> tm_mday)){ return 1; } return 0; } int main(){ DateCplusplus date; date.readValues(); cout<<"\nVerification of day and months values: "<<date.verifyValues()<<"\n"; cout<<"\nComparision of the day, the month and the year with the System current Date: "<<date.compareValues(); return 0; } };_C++_Macos_Terminal_Compiler Errors_Xcode Debugger - Fatal编程技术网

终端错误MacOS:/Applications/Xcode.app/Contents/Developer/Toolchains/xcodefault.xctoolchain/usr/include/c++/v1/istream:1634:1:注意: 当我尝试运行C++程序时,会产生错误: #include <iostream> #include <ctime> //standard c++ library of time.h using namespace std; class DateCplusplus{ private: int _day, _month, _year; //define variable public: void readValues(){ cout<<"Enter the day value: "; cin>>_day; cout<<"\nEnter the month value: "; cin>>_month; cout>>_year; _year = _year - 1900; } int verifyValues(){ if(_day>=1 && _day <=31 && _month>=1 && _month<= 12){ return 1; } return 0; } int compareValues(){ time_t now = time(0); tm *ltm = localtime(&now); if((_year == ltm -> tm_year) && (_month ==1 +ltm -> tm_mon) && (_day == ltm -> tm_mday)){ return 1; } return 0; } int main(){ DateCplusplus date; date.readValues(); cout<<"\nVerification of day and months values: "<<date.verifyValues()<<"\n"; cout<<"\nComparision of the day, the month and the year with the System current Date: "<<date.compareValues(); return 0; } };

终端错误MacOS:/Applications/Xcode.app/Contents/Developer/Toolchains/xcodefault.xctoolchain/usr/include/c++/v1/istream:1634:1:注意: 当我尝试运行C++程序时,会产生错误: #include <iostream> #include <ctime> //standard c++ library of time.h using namespace std; class DateCplusplus{ private: int _day, _month, _year; //define variable public: void readValues(){ cout<<"Enter the day value: "; cin>>_day; cout<<"\nEnter the month value: "; cin>>_month; cout>>_year; _year = _year - 1900; } int verifyValues(){ if(_day>=1 && _day <=31 && _month>=1 && _month<= 12){ return 1; } return 0; } int compareValues(){ time_t now = time(0); tm *ltm = localtime(&now); if((_year == ltm -> tm_year) && (_month ==1 +ltm -> tm_mon) && (_day == ltm -> tm_mday)){ return 1; } return 0; } int main(){ DateCplusplus date; date.readValues(); cout<<"\nVerification of day and months values: "<<date.verifyValues()<<"\n"; cout<<"\nComparision of the day, the month and the year with the System current Date: "<<date.compareValues(); return 0; } };,c++,macos,terminal,compiler-errors,xcode-debugger,C++,Macos,Terminal,Compiler Errors,Xcode Debugger,终端中显示的错误为: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/istream:1634:1:注意: 已忽略候选模板:无法将“基本”istream与“基本”ostream匹配 运算符>>基本\u istream&\uuuu is,位集&\uuux 你能帮我找到我的错误吗 谢谢大家! 您的主函数不能包含任何类,因此我从类DateCplusplus

终端中显示的错误为: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/istream:1634:1:注意: 已忽略候选模板:无法将“基本”istream与“基本”ostream匹配 运算符>>基本\u istream&\uuuu is,位集&\uuux

你能帮我找到我的错误吗


谢谢大家!

您的主函数不能包含任何类,因此我从类DateCplusplus中提取了主函数,您的语法错误为cou>>\u年,它必须是cout
#define _CRT_SECURE_NO_WARNINGS


#include <iostream>
#include <ctime> 

using namespace std;

class DateCplusplus {
private:
    int _day, _month, _year; //define variable 
public:
    void readValues() {
        cout << "Enter the day value: ";
        cin >> _day;
        cout << "\nEnter the month value: ";
        cin >> _month;
        cout << _year;
        _year = _year - 1900;
    }

    int verifyValues() {
        if (_day >= 1 && _day <= 31 && _month >= 1 && _month <= 12) {
            return 1;
        }
        return 0;
    }

    int compareValues() {
        time_t now = time(0);
        tm* ltm = localtime(&now);
        if ((_year == ltm->tm_year) && (_month == 1 + ltm->tm_mon) && (_day == ltm->tm_mday)) {
            return 1;
        }
        return 0;
    }
};



    int main() {
        DateCplusplus date;
        date.readValues();
        cout << "\nVerification of day and months values: " << date.verifyValues() << "\n";
        cout << "\nComparision of the day, the month and the year with the System current Date: " << date.compareValues();
        return 0;
    }