c++构造函数,析构函数,类型转换错误
C++ constructor, destructor, type conversion error
嘿,伙计们,我正试图创建一个模块的实现文件。它有我创建的头文件和一个。cc文件。在我的。cc文件中,我最初有一个main函数,但是由于这是一个类的赋值,它要求在实现中没有main函数。
9 #include <curses.h>
10 #include <sys/time.h>
11 #include <time.h>
12 #include "fmttime.h"
13
14
15 struct ExpandedTime
16 {
17
18 int et_usec;
19 int et_sec;
20 int et_min;
21 int et_hour;
22
23 };
24 ExpandedTime* localTime(struct timeval* tv, ExpandedTime* etime);
25
26
27 struct timeval tv;
28 struct ExpandedTime etime;
29 gettimeofday(&tv, NULL);
30 localTime(&tv,&etime);
31
32
33
34 ExpandedTime* localTime(struct timeval* tv, ExpandedTime* etime)
35 {
36 tzset(); // Corrects timezone
37
38 int epochT = (tv->tv_sec) - timezone; // Epoch seconds with
39 int epochUT = tv->tv_usec; // Timezone correction
40
41 int seconds = epochT % 60;
42 epochT /= 60;
43 etime->et_sec = seconds;
44 etime->et_usec = epochUT;
45
46 int minutes = epochT % 60;
47 epochT /= 60;
48 etime->et_min = minutes;
49
50 int hours = (epochT % 24) + daylight; // Hours with DST correction
对不起,最后几行被剪掉了,在putty中复制粘贴Mcedit很糟糕。无论如何,第29行和30行给了我一个构造函数,析构函数或类型转换错误,我不知道为什么。当我有一个包含这些语句的main函数时,一切都很好。但当我移除了主…它就这么坏了。如有任何帮助,不胜感激。
27 struct timeval tv;
28 struct ExpandedTime etime;
29 gettimeofday(&tv, NULL);
30 localTime(&tv,&etime);
此代码不在任何函数内部。它赤裸地坐在全球范围的荒野中。它需要在函数中显示出来,任何函数都可以。外面有狼。
相关文章:
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- C++:用户定义的显式类型转换函数错误
- LINUX 操作系统上的错误:令牌之前预期的构造函数、析构函数或类型转换'('?
- 指向类成员函数的指针中存在类型转换错误
- 错误 c++ 在令牌之前'('预期的构造函数、析构函数或类型转换
- 错误:在“(”标记之前进行预期的构造函数、析构函数或类型转换.即使我有一个构造函数
- Mat的convertTo函数在OpenCV中将灰度图像的类型转换为CV_32F时抱怨断言错误
- 获取错误:在“(”标记之前进行预期的构造函数、析构函数或类型转换
- Vulkan API 调试函数指针类型转换错误
- 模板扣除 /类型转换错误
- 为什么缩小转换范围不能防止错误类型的map.insert()失败
- 错误:令牌之前的预期构造函数、析构函数或类型转换'*'
- 尝试生成C++ .DLL的视觉对象类型/转换错误
- 在 CUDA 中使用内部类型转换的奇怪错误
- 需要构造函数/析构函数/类型转换错误
- C++模板错误:'<'令牌之前的预期构造函数、析构函数或类型转换
- 迭代器错误从非标量类型转换为非标量类型
- C++类型转换错误
- 为什么数据类型转换错误只出现在C++中而不出现在C中
- 无法将类型转换为类型*-C++编译错误