找回密码
 注册
搜索
热搜: 超星 读书 找书
查看: 907|回复: 3

[【解决】] VC error 拜求VC高手帮我看一下

[复制链接]
发表于 2005-9-14 09:38:06 | 显示全部楼层 |阅读模式
globals.cpp
E:\\News Arthur\\SVM\\2\\globals.cpp(115) : error C2144: syntax error : missing ')' before type 'char'
E:\\News Arthur\\SVM\\2\\globals.cpp(115) : error C2059: syntax error : ')'
E:\\News Arthur\\SVM\\2\\globals.cpp(116) : error C2143: syntax error : missing ';' before '{'
E:\\News Arthur\\SVM\\2\\globals.cpp(116) : error C2065: 'error_msg' : undeclared identifier
E:\\News Arthur\\SVM\\2\\globals.cpp(116) : error C2065: 'the_error' : undeclared identifier
E:\\News Arthur\\SVM\\2\\globals.cpp(118) : error C2143: syntax error : missing ';' before '{'
E:\\News Arthur\\SVM\\2\\globals.cpp(118) : error C2440: '=' : cannot convert from 'char [1]' to 'int'
      This conversion requires a reinterpret_cast, a C-style cast or function-style cast
E:\\News Arthur\\SVM\\2\\globals.cpp(120) : error C2144: syntax error : missing ')' before type 'char'
E:\\News Arthur\\SVM\\2\\globals.cpp(120) : error C2059: syntax error : ')'
E:\\News Arthur\\SVM\\2\\globals.cpp(121) : error C2143: syntax error : missing ';' before '{'
E:\\News Arthur\\SVM\\2\\globals.cpp(123) : error C2143: syntax error : missing ';' before '{'
E:\\News Arthur\\SVM\\2\\globals.cpp(123) : error C2440: '=' : cannot convert from 'char [1]' to 'int'
      This conversion requires a reinterpret_cast, a C-style cast or function-style cast
E:\\News Arthur\\SVM\\2\\globals.cpp(127) : error C2601: &#39;<<&#39; : local function definitions are illegal
E:\\News Arthur\\SVM\\2\\globals.cpp(127) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.

代码如下:
#include \"stdafx.h\"
#include \"globals.h\"


SVMFLOAT x_i(const svm_example x, const SVMINT i)
{
    // return x by binary search
    SVMINT low=0;
    SVMINT high=x.length;
    SVMINT med;
    SVMFLOAT result;
    while(low<high)
    {
        med = (low+high)/2;
        if(x.example[med].index>=i)
        {
            high=med;
        }
        else
        {
            low=med+1;
        }
    }
    if((high < x.length) && (x.example[high].index==i))
    {
        result = x.example[high].att;
    }
    else
    {
        result = 0;
    }
    return result;
}


SVMFLOAT string2svmfloat(char* s)
{
    // number =~ [+-]?\\d+([.]\\d+)?([Ee][+-]?\\d+)?
    int size = 0;
    while(s[size] != &#39;\\0&#39;) size++;
   
    int char_read=0;
    SVMFLOAT number=0;
    int sign = 1;
    // sign
    if((size > 0) && (&#39;+&#39; == s[0]))
    {
        char_read++;
    }
    else if((size > 0) && (&#39;-&#39; ==s[0]))
    {
        char_read++;
        sign = -1;
    }
    // digits before \".\"
    while((char_read<size) && (s[char_read] >= &#39;0&#39;) && (s[char_read] <= &#39;9&#39;))
    {
        number=number*10+(s[char_read]-&#39;0&#39;);
        char_read++;
    }
    // digits after \".\"
    if((char_read<size) && ((&#39;.&#39; == s[char_read]) || (&#39;,&#39; == s[char_read])))
    {
        SVMFLOAT factor = 0.1;
        char_read++;
        while((char_read<size) && (s[char_read] >= &#39;0&#39;) && (s[char_read] <= &#39;9&#39;))
        {
            number=number+factor*(s[char_read]-&#39;0&#39;);
            char_read++;
            factor *= 0.1;
        }   
    }
    if(sign<0)
    {
        number = -number;
    }
    // exponent
    if((char_read<size) && ((&#39;e&#39; == s[char_read]) || (&#39;E&#39; == s[char_read])))
    {
        sign = 1;
        char_read++;
        if((char_read<size) && (&#39;+&#39; == s[char_read]))
        {
            char_read++;
        }
        else if((char_read<size) && (&#39;-&#39; == s[char_read]))
        {
            char_read++;
            sign = -1;
        }
        int exponent=0;
        while((char_read<size) && (s[char_read] >= &#39;0&#39;) && (s[char_read] <= &#39;9&#39;))
        {
            exponent = exponent*10+(s[char_read]-&#39;0&#39;);
            char_read++;
        }
        number = number*pow(10,sign*exponent);
    }
    if(char_read<size)
    {
        throw no_number_exception();
    }
    return number;
}

long get_time()
{
#ifdef use_time
    struct tms the_time;
    times(&the_time);
    return(the_time.tms_utime);
#else  return 0;
#endif}
   
    general_exception::general_exception(char* the_error)
    { error_msg = the_error; }
    general_exception::general_exception()
    { error_msg = \"\"; }
   
    read_exception::read_exception(char* the_error)
    { error_msg = the_error; }
    read_exception::read_exception()
    { error_msg = \"\"; }
   
   
    ostream& operator<< (ostream& data_stream, example_format& format)
    {
        if(format.sparse)
        {
            data_stream<<\"sparse\";
        }
        else
        {
            for(int i=1;i<=5;i++)
            {
                if(format.where_x == i)
                {
                    data_stream<<\"x\";
                }
                else if(format.where_y == i)
                {
                    data_stream<<\"y\";
                }
                else if (format.where_alpha == i)
                {
                    data_stream<<\"a\";
                }
            }
        }
        return data_stream;
    }
回复

使用道具 举报

selina.kd.li 该用户已被删除
发表于 2005-9-15 14:18:28 | 显示全部楼层
错误提示写的很清楚啊,错误行都标出来了,对照改就行了。如果还是改不好,那么,你先把你的115-127行是哪一部分标识清楚,我可以对照看看,如果能帮你就直接帮你改好。不然这样找,太麻烦了。
回复

使用道具 举报

selina.kd.li 该用户已被删除
发表于 2005-9-15 14:47:04 | 显示全部楼层
error_msg没有定义。如果我没猜错的话,ostream& operator<< (ostream& data_stream, example_format& format) 是127行。VC里有你这种<<的用法么?
回复

使用道具 举报

selina.kd.li 该用户已被删除
发表于 2005-9-15 14:53:39 | 显示全部楼层
还有,endif后面少了个‘;’。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|网上读书园地

GMT+8, 2024-5-18 22:43 , Processed in 0.302570 second(s), 8 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表