VC6新建单文档工程;
视类添加2个函数;
int getmax(int a,int b)
{
return a>=b?a:b;
}
int two(int a)
{
return a * 2;
}
调用,输出,
void CMingView::OnDraw(CDC* pDC)
{
CMingDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CString str1;
int x;
x = getmax(9, 99);
str1.Format("%d", x);
pDC->TextOut(50, 50, str1);
x = two(100);
str1.Format("%d", x);
pDC->TextOut(50, 80, str1);
}
int getmax(int a,int b)
{
return a>=b?a:b;
}
getmax是函数名;后面括号中是参数;此函数带有2个参数;
int two(int a)
{
return a * 2;
}
two是函数名;后面括号中是参数;此函数带有1个参数;