C++老大们请来看看程序 我的程序如下。但是不知道错哪了
分三个文档/*************Circle.h*****************/#include<string>usingnamespacestd;classC...
分三个文档
/*************Circle.h*****************/
# include <string>
using namespace std ;
class Circle
{
public :
Circle (int) ;
float getArea () ;
const static string code ;
private :
int r ;
} ;
/******************Circle.cpp*************************/
# include "Circle.h"
# include <string>
using namespace std ;
Circle :: Circle (int rc) : r (rc) {}
float Circle :: getArea ()
{
int s ;
s = 3.14 * r * r ;
return s ;
}
const string Circle :: code = "Circle" ;
/*****************main.cpp*************************/
# include "Circle.h"
# include <string>
using namespace std ;
int main ()
{
Circle c (5) ;
return 0 ;
}
/**********************报错***********************/
Circle.cpp(1) : error C2018: unknown character '0xef'
Circle.cpp(1) : error C2018: unknown character '0xbb'
Circle.cpp(1) : error C2018: unknown character '0xbf'
Circle.cpp(1) : error C2014: preprocessor command must start as first nonwhite s
pace
D:\C++\Microsoft Visual Studio\VC98\Include\istream(547) : warning C4530: C++ ex
ception handler used, but unwind semantics are not enabled. Specify -GX
Circle.cpp(7) : error C2653: 'Circle' : is not a class or namespace name
Circle.cpp(7) : error C2550: 'Circle' : constructor initializer lists are only a
llowed on constructor definitions
Circle.cpp(7) : warning C4508: 'Circle' : function should return a value; 'void'
return type assumed
Circle.cpp(9) : error C2653: 'Circle' : is not a class or namespace name
Circle.cpp(15) : error C2065: 'r' : undeclared identifier
Circle.cpp(21) : error C2653: 'Circle' : is not a class or namespace name 展开
/*************Circle.h*****************/
# include <string>
using namespace std ;
class Circle
{
public :
Circle (int) ;
float getArea () ;
const static string code ;
private :
int r ;
} ;
/******************Circle.cpp*************************/
# include "Circle.h"
# include <string>
using namespace std ;
Circle :: Circle (int rc) : r (rc) {}
float Circle :: getArea ()
{
int s ;
s = 3.14 * r * r ;
return s ;
}
const string Circle :: code = "Circle" ;
/*****************main.cpp*************************/
# include "Circle.h"
# include <string>
using namespace std ;
int main ()
{
Circle c (5) ;
return 0 ;
}
/**********************报错***********************/
Circle.cpp(1) : error C2018: unknown character '0xef'
Circle.cpp(1) : error C2018: unknown character '0xbb'
Circle.cpp(1) : error C2018: unknown character '0xbf'
Circle.cpp(1) : error C2014: preprocessor command must start as first nonwhite s
pace
D:\C++\Microsoft Visual Studio\VC98\Include\istream(547) : warning C4530: C++ ex
ception handler used, but unwind semantics are not enabled. Specify -GX
Circle.cpp(7) : error C2653: 'Circle' : is not a class or namespace name
Circle.cpp(7) : error C2550: 'Circle' : constructor initializer lists are only a
llowed on constructor definitions
Circle.cpp(7) : warning C4508: 'Circle' : function should return a value; 'void'
return type assumed
Circle.cpp(9) : error C2653: 'Circle' : is not a class or namespace name
Circle.cpp(15) : error C2065: 'r' : undeclared identifier
Circle.cpp(21) : error C2653: 'Circle' : is not a class or namespace name 展开
2个回答
展开全部
没错啊,将程序放到linux系统下:
$g++ main.cpp circle.cpp
直接编译,可以通过并生成可执行文件
你是不是编译的时候没加上circle.cpp
$g++ main.cpp circle.cpp
直接编译,可以通过并生成可执行文件
你是不是编译的时候没加上circle.cpp
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询