簡體   English   中英

我該如何解決一元論據中的錯誤?

[英]How can i solve the error that in argument to unary?

#include<iostream>
#include<fstream>
#include<string>
using namespace std;




int main(){
    const char *months[12]={"January", "February", "March", "April","May", "June", "July", "August","September", "October", "November", "December"}; // to check month is that true or false.
    int day,year;
    string first,last,month;
    Person p(first,last,day,month,year);
    ifstream infile;                   //opening input file
    infile.open("input.txt"); 

    while(!infile.eof()) {

        }
    }
}

我檢查輸入文件中的值並在 output 文件中打印正確的值。我調用 setmonth function 在檢查輸入文件中的日期和年份是否正確后檢查月份是否正確。

我該如何解決這個錯誤? 什么是 printInfo FUNCTION 參數?

所以第一個問題是你寫

if(!p.setMonth(month)) 

這意味着setMonth應該返回一個可以傳遞給! . 但是如果你看一下setMonth你會看到這個

void setMonth(string m){}

setMonth是一個void function,它不返回任何東西,所以.p.setMonth()是非法的。

可能它應該返回一個bool

bool setMonth(string m) { ... }

我想void printInfo(ostream){}應該是void printInfo(ostream&){} 。這是將 output stream 傳遞給 ZC1C425268E68385D1AB5074 的正常方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM