Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/152.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
开发c++;源文件未编译 我用DeV C++开发了C++应用程序,用GETTER和SETER和构造函数编写。我通过构造函数发送日、小时、分钟、秒变量,并希望打印它们_C++_Dev C++ - Fatal编程技术网

开发c++;源文件未编译 我用DeV C++开发了C++应用程序,用GETTER和SETER和构造函数编写。我通过构造函数发送日、小时、分钟、秒变量,并希望打印它们

开发c++;源文件未编译 我用DeV C++开发了C++应用程序,用GETTER和SETER和构造函数编写。我通过构造函数发送日、小时、分钟、秒变量,并希望打印它们,c++,dev-c++,C++,Dev C++,但在我运行和编译时会出现错误,例如“源文件未编译” 我如何解决这个问题?我已经删除了collect2.exe文件,但问题仍然存在 Sinif.CPP #include "Sinif.h" #include <iostream> #include <iomanip> using namespace std; Sinif::Sinif(int d,int h, int m, int s) { day=d; hour = h; minute = m;

但在我运行和编译时会出现错误,例如“源文件未编译”

我如何解决这个问题?我已经删除了collect2.exe文件,但问题仍然存在

Sinif.CPP

#include "Sinif.h"
#include <iostream>
#include <iomanip>
using namespace std;

Sinif::Sinif(int d,int h, int m, int s) {
   day=d;
   hour = h;
   minute = m;
   second = s;

}
int Sinif::getDay() const {
   return day;
}
 void Sinif::setDay(int d) {
   day = d;
}
int Sinif::getHour() const {
   return hour;
}
 void Sinif::setHour(int h) {
   hour = h;
}
 int Sinif::getMinute() const {
   return minute;
}
 void Sinif::setMinute(int m) {
   minute = m;
}
int Sinif::getSecond() const {
   return second;
}
 void Sinif::setSecond(int s) {
   second = s;
}
 void Time::setTime(int d,int h, int m, int s) {
   day=d;
   hour = h;
   minute = m;
   second = s;
}
 void Time::print() const {
   cout << setfill('0');   
   cout << setw(2) << day 
   cout <<":"<< setw(2) << hour  
        << ":" << setw(2) << minute
        << ":" << setw(2) << second << endl;
}
#include <iostream>
#include "Sinif.h" 
using namespace std;
int main() {
   Sinif t1(25,23, 59, 59);   // Test constructor
   // Test all public member functions
   t1.print(); 
   t1.setDay(17);
   t1.setHour(12);
   t1.setMinute(30);
   t1.setSecond(15);
   t1.print();       // 12:30:15
   cout << "Day is "    << t1.getDay()    << endl;
   cout << "Hour is "   << t1.getHour()   << endl;
   cout << "Minute is " << t1.getMinute() << endl;
   cout << "Second is " << t1.getSecond() << endl;

   Sinif t2;     // Test constructor with default values for hour, minute and second
   t2.print();  // 00:00:00
   t2.setTime(10,1, 2, 3);
   t2.print();  // 01:02:03

   Sinif t3(12); // Use default values for minute and second
   t3.print();  // 12:00:00

}
主CPP

#include "Sinif.h"
#include <iostream>
#include <iomanip>
using namespace std;

Sinif::Sinif(int d,int h, int m, int s) {
   day=d;
   hour = h;
   minute = m;
   second = s;

}
int Sinif::getDay() const {
   return day;
}
 void Sinif::setDay(int d) {
   day = d;
}
int Sinif::getHour() const {
   return hour;
}
 void Sinif::setHour(int h) {
   hour = h;
}
 int Sinif::getMinute() const {
   return minute;
}
 void Sinif::setMinute(int m) {
   minute = m;
}
int Sinif::getSecond() const {
   return second;
}
 void Sinif::setSecond(int s) {
   second = s;
}
 void Time::setTime(int d,int h, int m, int s) {
   day=d;
   hour = h;
   minute = m;
   second = s;
}
 void Time::print() const {
   cout << setfill('0');   
   cout << setw(2) << day 
   cout <<":"<< setw(2) << hour  
        << ":" << setw(2) << minute
        << ":" << setw(2) << second << endl;
}
#include <iostream>
#include "Sinif.h" 
using namespace std;
int main() {
   Sinif t1(25,23, 59, 59);   // Test constructor
   // Test all public member functions
   t1.print(); 
   t1.setDay(17);
   t1.setHour(12);
   t1.setMinute(30);
   t1.setSecond(15);
   t1.print();       // 12:30:15
   cout << "Day is "    << t1.getDay()    << endl;
   cout << "Hour is "   << t1.getHour()   << endl;
   cout << "Minute is " << t1.getMinute() << endl;
   cout << "Second is " << t1.getSecond() << endl;

   Sinif t2;     // Test constructor with default values for hour, minute and second
   t2.print();  // 00:00:00
   t2.setTime(10,1, 2, 3);
   t2.print();  // 01:02:03

   Sinif t3(12); // Use default values for minute and second
   t3.print();  // 12:00:00

}
#包括
#包括“Sinif.h”
使用名称空间std;
int main(){
Sinif t1(25,23,59,59);//测试构造函数
//测试所有公共成员函数
t1.print();
t1.设定日(17);
t1.设定小时(12);
t1.设定分钟(30);
t1.设定秒(15);
t1.print();//12:30:15
我不知道你该做什么
阅读完整的构建输出,它将告诉您哪里出了问题,哪里出了问题

在这种情况下,这可能是由于以下原因:

void Time::setTime(int d,int h, int m, int s) {
   day=d;
   hour = h;
   minute = m;
   second = s;
}
(您的类称为
Sinif
,而不是
Time

…这是:

cout << setw(2) << day 

cout除非你的程序名为“collect2.exe”,否则该程序是工具链中非常重要的一部分,你绝对不应该删除它。你到底得到了什么错误?Mark 1眼球说
Time::setTime
应该是
Sinif::setTime
cout你为什么要删除GCC的一部分?