注册 登录
编程论坛 C++教室

各位大虾帮忙看一下,这道程序出错在哪里

a654548060 发布于 2010-06-12 22:12, 466 次点击
#include <iostream.h>
static string GetCustomerName(int);
void Call_GetCustomerName();
int main(void)
{
    Call_GetCustomerName();
    return 1;
}
void Call_GetCustomerName()
{
    cout<<GetCustomerName(125);
}
static string GetCustomerName(int customerId)
{
    string ret_name;
    if(customerId>=1&&customerId<=100)
    {
        ret_name="A Group";
    }
    else
    {
        ret_name="Unknow";
    }
    return ret_name;
}



Compiling...
Cpp1.cpp
C:\Documents and Settings\longtingwei\桌面\新建文件夹\Cpp1.cpp(3) : error C2146: syntax error : missing ';' before identifier 'GetCustomerName'
C:\Documents and Settings\longtingwei\桌面\新建文件夹\Cpp1.cpp(3) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

Cpp1.obj - 2 error(s), 0 warning(s)

4 回复
#2
南国利剑2010-06-12 22:42
程序代码:
#include <iostream>
#include<string>//string 定义在这个头文件里头 ,要加上这个头文件
using namespace std;

static string GetCustomerName(int);
void Call_GetCustomerName();
int main(void)
{
    Call_GetCustomerName();
    return 1;
}
void Call_GetCustomerName()
{
    cout<<GetCustomerName(125);
}
static string GetCustomerName(int customerId)
{
    string ret_name;
    if(customerId>=1&&customerId<=100)
    {
        ret_name="A Group";
    }
    else
    {
        ret_name="Unknow";
    }
    return ret_name;
}


[ 本帖最后由 南国利剑 于 2010-6-12 22:44 编辑 ]
#3
a6545480602010-06-13 14:51
回复 2楼 南国利剑
谢谢  我之前也加过#include<string.h>不过编译的时候显示不出来,我想问一下#include<string>和#include<string.h>有什么区别
#4
py823856182010-06-13 15:38
头文件就错了呵`
#5
飞天猪10002010-06-19 08:32
以下是引用py82385618在2010-6-13 15:38:05的发言:

头文件就错了呵`
我也想问一下假如我是用#include<iostream.h>和#include<string.h>编译呢?
那应该怎样修改?
1