C\C++菜鸟问题集1
代码:
#include <iostream>
using namespace std;
class Clock
{
int hour, minute, second;
public:
Clock(int h, int m, int s) //构造函数定义 ,无返回值类型
{
if(s<0) second=0;
if (s>=60) second =s%60;
else second=s;
if(m<0) minute=0;
if (m>=60) minute =m%60;
else minute=m;
if(h<0) hour=0;
if (h>=24) hour=h%24;
else hour=h;
}
void print(){ cout<<hour<<”:”<<minute<<”:”<<second<<endl; }
};
void main()
{
Clock aClock(100,100,200);
//创建一个Clock类的对象aClock
aClock.print(); //类成员函数调用
}
错误:
以上代码的错误只是用了中文的引号而已,这个是超级菜鸟错误……
相关文档:
#include <stdio.h>
#include <windows.h>
#include <mysql.h>
#define host "localhost"
#define username "root"
#define password "123"
#define database "oa"
MYSQL *conn;
int main()
{
MYSQL_RES *res_set;
MYSQL_ROW row;
unsigned int i,ret;
FILE *fp;
MYSQL_FIELD *field;
......
VB
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
MSComm1.CommPort = i1
MSComm1.PortOpen = True
MSComm1.InputMode = comInputModeBinary
MSComm1.InBufferCount = 0
& ......
楼主发表于:2009-07-24 10:11:03是这样的,去一家公司面试,遇到了一道c语言的题,个人
感觉很怪,以前没见过类似的,然后主考官说这是关于C语言强弱类型转换什么的,我感觉他
自己都不完全清楚,然后回来在网上查到这是英国剑桥大学网上出的计算机题 :
#include <stdio.h>
#define init_employee(X,Y) {(X),(Y),wage ......
C语言函数的出口:return语句(高质量c/c++编程指南) 收藏
今天看到了一篇关于c/c++语言中,对于函数出口处:return语句的正确性和效率性的检查问题。平时我们都不太看重return语句的,认为它简单,不是很重要,其实不然,return语句要是写的不好,很容易导致效率低下,甚至会出错!特别是在处理指针时。
下面看看要 ......
char dec2hexChar(short int n) {
if ( 0 <= n && n <= 9 ) {
return char( short('0') + n );
} else if ( 10 <= n && n <= 15 ) {
return char( short('A') + n - 10 );
} else {
return char(0);
}
}
short int h ......