| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 825 人关注过本帖
标题:很简单的问题
取消只看楼主 加入收藏
chenjiang001
Rank: 1
等 级:新手上路
帖 子:133
专家分:0
注 册:2006-3-21
收藏
 问题点数:0 回复次数:2 
很简单的问题

#include "stdio.h"
#include <iostream.h>

class Location()
{
public:
Location(int xx=0,int yy=0);
Location(Location & p);
~Location();
int GetX(){return X;}
int GetY(){return Y;}
private:
int X,Y;
};
Location::Location(int xx,int yy)
{
X=xx;
Y=yy;
cout<<"constructor Object.\n";
}
Location::~Location()
{
cout<<X<<","<<Y<<"objiect destroyed."<<endl;
}
Location::Location(Location & p)
{
X=p.X;
Y=p.Y;
cout<<"copy constructor called.\n";
}
void f(Location p)
{
cout<<"Function"<<p.GetX()<<","<<p.GetY()<<endl;
}
void main()
{
Location B(1,2);
f(B);
}

这个程序应该没问题吧.怎么通不过编译?
王高手指点!

搜索更多相关主题的帖子: private include Object public return 
2007-01-03 12:42
chenjiang001
Rank: 1
等 级:新手上路
帖 子:133
专家分:0
注 册:2006-3-21
收藏
得分:0 

error C2871: 'std' : does not exist or is not a namespace
D:\chenjiang\\gouzao\gouzao.cpp(12) : error C2143: syntax error : missing ';' before 'public'
D:\chenjiang\\gouzao\gouzao.cpp(14) : error C2065: 'p' : undeclared identifier
D:\chenjiang\\gouzao\gouzao.cpp(14) : error C2296: '&' : illegal, left operand has type 'int (__cdecl *)(void)'
D:\chenjiang\\gouzao\gouzao.cpp(14) : error C2660: 'Location' : function does not take 1 parameters
D:\chenjiang\\gouzao\gouzao.cpp(15) : warning C4552: '~' : operator has no effect; expected operator with side-effect
D:\chenjiang\\gouzao\gouzao.cpp(16) : error C2601: 'GetX' : local function definitions are illegal
D:\chenjiang\\gouzao\gouzao.cpp(17) : error C2601: 'GetY' : local function definitions are illegal
D:\chenjiang\gouzao\gouzao.cpp(18) : error C2143: syntax error : missing ';' before 'private'
D:\chenjiang\\gouzao\gouzao.cpp(21) : error C2653: 'Location' : is not a class or namespace name
D:\chenjiang\\gouzao\gouzao.cpp(23) : error C2065: 'X' : undeclared identifier
D:\chenjiang\\gouzao\gouzao.cpp(24) : error C2065: 'Y' : undeclared identifier
D:\chenjiang\\gouzao\gouzao.cpp(26) : warning C4508: 'Location' : function should return a value; 'void' return type assumed
D:\chenjiang\\gouzao\gouzao.cpp(27) : error C2653: 'Location' : is not a class or namespace name
D:\chenjiang\\gouzao\gouzao.cpp(28) : error C2084: function 'int __cdecl Location(void)' already has a body
D:\chenjiang\\gouzao\gouzao.cpp(31) : error C2653: 'Location' : is not a class or namespace name
D:\chenjiang\\gouzao\gouzao.cpp(31) : error C2563: mismatch in formal parameter list
D:\chenjiang\\gouzao\gouzao.cpp(32) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
D:\chenjiang\\gouzao\gouzao.cpp(37) : error C2146: syntax error : missing ')' before identifier 'p'
D:\chenjiang\\gouzao\gouzao.cpp(37) : error C2182: 'f' : illegal use of type 'void'
D:\chenjiang\\gouzao\gouzao.cpp(37) : error C2440: 'initializing' : cannot convert from '' to 'int'
Context does not allow for disambiguation of overloaded function
D:\chenjiang\\gouzao\gouzao.cpp(37) : error C2059: syntax error : ')'
D:\chenjiang\\gouzao\gouzao.cpp(38) : error C2143: syntax error : missing ';' before '{'
D:\chenjiang\\gouzao\gouzao.cpp(38) : error C2447: missing function header (old-style formal list?)
D:\chenjiang\\gouzao\gouzao.cpp(43) : error C2146: syntax error : missing ';' before identifier 'B'
D:\chenjiang\\gouzao\gouzao.cpp(43) : warning C4551: function call missing argument list
D:\chenjiang\\gouzao\gouzao.cpp(43) : error C2065: 'B' : undeclared identifier
Error executing cl.exe.

gouzao.exe - 24 error(s), 3 warning(s)
加了后还是出现一大队错误。
真不知该怎么改.
望指点


2007-01-03 13:04
chenjiang001
Rank: 1
等 级:新手上路
帖 子:133
专家分:0
注 册:2006-3-21
收藏
得分:0 
我也不知道

2007-01-03 13:16
快速回复:很简单的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030259 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved