
很基本!很简单的问题~关于类 如何在MAIN函数中调用 类中的函数
我还是菜鸟刚学类,这里面我构造了3个成员函数(第二个函数内容被我省略了)但是每次按运行,他总说:MAIN中:implicitdeclarationoffunction`i...
我还是菜鸟 刚学类,这里面我构造了3个成员函数(第二个函数内容被我省略了)
但是每次按运行,他总说:
MAIN中: implicit declaration of function `int settime(...)'
我不知道如何将类中的函数调用到MAIN函数中。..好郁闷啊 求好心人~~
#include "stdio.h"
#include<iostream>
using namespace std;
class Cdate
{
private:
int m_year,m_month,m_day;
public :
Cdate(int y,int m,int d)
{
m_year =y;
m_month=m;
m_day =d;
}
void settime ();
int getadd () ;
void showtime();
};
void Cdate::settime()
{
cin>>m_year>>m_month>>m_day;
}
int Cdate::getadd()
{
}
void Cdate::showtime()
{
cout<<m_year<<m_month<<m_day;
}
int main(void)
{
cout<<"请输入年、月、日:";
settime();
getadd();
showtime();
}
C++的 展开
但是每次按运行,他总说:
MAIN中: implicit declaration of function `int settime(...)'
我不知道如何将类中的函数调用到MAIN函数中。..好郁闷啊 求好心人~~
#include "stdio.h"
#include<iostream>
using namespace std;
class Cdate
{
private:
int m_year,m_month,m_day;
public :
Cdate(int y,int m,int d)
{
m_year =y;
m_month=m;
m_day =d;
}
void settime ();
int getadd () ;
void showtime();
};
void Cdate::settime()
{
cin>>m_year>>m_month>>m_day;
}
int Cdate::getadd()
{
}
void Cdate::showtime()
{
cout<<m_year<<m_month<<m_day;
}
int main(void)
{
cout<<"请输入年、月、日:";
settime();
getadd();
showtime();
}
C++的 展开
1个回答
展开全部
#include "stdio.h"
#include<iostream>
using namespace std;
class Cdate
{
private:
int m_year,m_month,m_day;
public :
Cdate(int y,int m,int d)
{
m_year =y;
m_month=m;
m_day =d;
}
void settime ();
int getadd () ;
void showtime();
};
void Cdate::settime()
{
std::cin>>m_year>>m_month>>m_day;
}
int Cdate::getadd()
{
}
void Cdate::showtime()
{
std::cout<<m_year<<m_month<<m_day;
}
int main(void)
{
Cdate date(0,0,0);//要有对象才能调类里的非静态函数
std::cout<<"请输入年、月、日:";
date.settime();
date.getadd();
date.showtime();
}
#include<iostream>
using namespace std;
class Cdate
{
private:
int m_year,m_month,m_day;
public :
Cdate(int y,int m,int d)
{
m_year =y;
m_month=m;
m_day =d;
}
void settime ();
int getadd () ;
void showtime();
};
void Cdate::settime()
{
std::cin>>m_year>>m_month>>m_day;
}
int Cdate::getadd()
{
}
void Cdate::showtime()
{
std::cout<<m_year<<m_month<<m_day;
}
int main(void)
{
Cdate date(0,0,0);//要有对象才能调类里的非静态函数
std::cout<<"请输入年、月、日:";
date.settime();
date.getadd();
date.showtime();
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?

2023-06-12 广告
单片机,即单片微控制器,也称为单片微型计算机,是将中央处理器(CPU)、存储器(ROM,RAM)、输入/输出接口和其他功能部件集成在一块 在一个小块的集成电路上,从而实现对整个电路或系统的数字式控制。单片机不是完成某一个逻辑功能的芯片,而是...
点击进入详情页
本回答由意法半导体(中国)投资有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询