类头文件定义
作者:互联网
所以到底什么问题啊,Tdate怎么定义
#ifndef TDATE
#define TDATE
class Tdate{
public:
void Set(int,int,int);
int IsLeapYear();
void Print();
private:
int month;
int day;
int year;
};
#endif
#include"Tdate.h"
#include<iostream>
using namespace std;
void Tdate::Set(int m,int d,int y){
month=m;day=d;year=y;
}
int Tdate::IsLeapYear(){
return (year%4==0&&year%100!=0)||(year%400==0);
}
void Tdate::Print(){
cout<<month<<"/"<<day<<"/"<<year<<endl;
void someFunc(Tdate* pS){
pS->Print();
if(pS->IsLeapYear())
cout<<"oh oh\n";
else
cout<<"right\n";
}
int main(){
Tdate s;
s.Set(2,15,1998);
someFunc(&s);
}
}
标签:pS,头文件,定义,int,void,Tdate,Print,cout 来源: https://blog.csdn.net/weixin_50803539/article/details/121064720