亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

C++ 接口和實現分離實現錯誤

C++ 接口和實現分離實現錯誤

C++
Jeremiah0 2018-02-18 06:09:25
上課的時候老師提到了個這個東西,然后給了代碼實例,可是無論如何執行main.cpp都會有些錯誤Example DATE class – Using METHOD Three?File 1 - Date.h? ?Header file?#pragma once? ? ? ? // needed to work class Date { public:? ? ?void get();? ? ? // function header for inputting the date? ? ?void write();? ? // function header for outputting the date private:? ? ?int month;? ? ? ?// month (between 1 and 12)? ? ?int day;? ? ? ? ?// day (between 1 and 31)? ? ?int year;? ? ? ? // year (between 0 and 99) }? ????File 2 – Date.cpp? Implementation file?#include <iostream> #include <iomanip> using namespace std; #include "Date.h"? // Include the library/file name of the class in quotes??void Date::get() {? ? ?char slash;? ? // Allows for inputting in the format MM/DD/YY? ? ?cin >> month >> slash >> day >> slash >> year; }??void Date::write() {? ? ?cout << "The date you entered was: " << setw(2) << month << "/" << setw(2) << day << "/" << setw(2) << year << endl; }???File 3 – Driver/Test fileImp.Date.cpp??#include <iostream> #include <iomanip> using namespace std; #include "Date.h"? ? ? // include DATE class header file name??int main () {? ? ?Date aDate;? ? ? ? // declaring A as a type Date??? ? cout << "Enter a date in the form MM/DD/YY:? \n";? ? ?aDate.get();? ? ? ?// Function which will input our date? ? ?aDate.write();? ? ?// Function which will output our date? ? ?return 0;?
查看完整描述

目前暫無任何回答

  • 0 回答
  • 0 關注
  • 907 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號