| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 954 人关注过本帖
标题:为什么找不到执行文件?无法编译。
只看楼主 加入收藏
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
结帖率:100%
收藏
 问题点数:0 回复次数:8 
为什么找不到执行文件?无法编译。

//vcet.cpp--methods for vector class
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
#include"vect.h"

namespace vector
{
const double red_to_deg = 57.295774579893;
//private methods
//calculates magnitude form x and y
void vector:: set_mag()
{
mag = (x * x + y * y);
}
void vector:: set_ang()
{
if(x == 0 && y == 0)
ang = 0.0;
else atan2(y,x);
}
//set x form polar coordinate
void vector:: set_x()
{
x = mag * cos (ang);
}
//set y form polar coordinate
void vector:: set_y(ang);
{
y = mag * sin (ang);
}
//public methods
vector:: vector () //default constructor
{ x = y = mag = ang = 0;
mode = " r";
}
//constructor vector form rec coordinate if form is rec
//or else form pol coordinate if form is p
vector:: vector(double n1,double n2,char form)
{
made = form;
if (form == 'r')
{
x1=n1;
x2=n2;
set_mag;
set_ang;
}
else if (form =='p')
{
mag =n1;
ang =n2/rad_to_deg;
set_x();
srt_y();
}
else
{
cout<<"Incorrect 3rd argument to vector ()--";
cout<<"vector set to 0\n";
x = y = mag = ang =0.0;

mode = "r";
}
}
//set voctor form rec coordinate if form is r or else form polcoordinate
//if form is p
void vector:: set (double n1,double n2,char form)
{
mode = form;
if (form = 'r')
{
x = n1;
y = n2;
set_mag();
set_ang();
}
else if (form == 'p')
{
mag = n1;
ang = n2/rad_to_deg;
set_x();
set_y();
}
else
{
cout<<"Incorrect 3rd argument to vector ()--";
cout<<"vector set to 0\n";
x = y = mag =ang = 0.0;
mode = 'r';
}
}
vector:: ~vector() //default
{
}
void vector:: polar_mode() //set to polar mode
{
mode = 'p';
}
void vector:: rect_mode() //set to rectangular mode
{
mode = 'r';
}
//operate overloading
//add two vectors
vector vector:: operator+ (const vector & b)const
{
return vector (x - b.x,y - b.y);
}
//reverse sign of vector
vector vector:: operator-()const
{
return vector (-x,-y);
}
//mutiple vector by n
vector vrctor:: operator*()const
{
return vector (n*x,n*y);
}
//firend methods
//multiply n by vector add
vector operator * (double n,const vector & a)
{
return a * n;
}
//display rec coordinate if mode is r
//else display polar coordinade if mode is p
ostream & operator <<(ostream & os,const vector & v)
{
if (v.mode == 'r')
os<<" (x,y)=("<<v.x<<","<<v.y<<")";
else if (v.mode == 'p')
{
os <<"(m,a) = (" <<v.mg<<","
<<v.ang * rad_to_deh <<")";
}
else
os << "vector object mode is invalid ";
return os;
}
} //end namespace vector
int main()
{
using vector:: vector;
srand(time (0) );
double direction;
vector step;
vector result (0.0,0.0);
unsigned long steps = 0;
double target;
double dstep;
cout<<"Enter target distance (q to quit):";
while(cin>>target)
{
cout<<"Enter step longth:";
if (!(cin>>target))
break;
while (result .magval()<target)
{
directiom = rand ()%360;
step.set(dstep,direction,'p';
result = result + step;
steps++;
}
cout<<"after"<<steps<<"steps,the subject;
"has the following location:\n";
cout<<result<<:\n";
result.polar_mode();
cout<<"or\n"<<result<<"\n";
cout<<"Average outward distance per step ="
<<result.magval ()/steps<<"\n";
steps =0;
result.set(0.0,0.0);
cout<<"Enter target distance (q to quit):";
}
cout<<"Bye:";
return 0;
}











搜索更多相关主题的帖子: vector include 文件 mag 编译 
2006-12-05 19:35
kai
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:52
帖 子:3450
专家分:59
注 册:2004-4-25
收藏
得分:0 
你的头文件在哪里, 一块儿贴上来.

自由,民主,平等,博爱,进步.
中华民国,我的祖国,中华民国万岁!中华民国加油!
本人自愿加入中国国民党,为人的自由性,独立性和平等性而奋斗!
2006-12-06 07:14
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 
//vect.h--vector class with <<,mode state
#ifndef vector_h_
#define vector_h_
namespace vector
{
class
{
private:
double x; //horizontal value
double y; //vertical value

double mag; //length of vector
double ang; //direction of vector
char mode; //'r' = reg 'p' = pol
//private methods for setting value
void set_mag();
void set_ang();
void set_x();
void set_y();
public:
vector();
vector(double n1,double n2,char form = 'r')
void set (double n1,double n2,char form = 'r')
~voctor ();
double xval () const {return x;} //report x value
double yval () const {return y:} //report y value
double magval () const {return mag;} //report magnitude
double angval () const {return ang;} //report angle
void polar_mode (); //set mode to 'p'
void rect_mode (); //set mode to 'r'
//operate overloading
vector operate+ (const vector & b) const;
vector operate_ (const vector & b) const;
vector operate_ () const;
vector operate_ (dounle n) const;
//friends
friend vector operate* (double n,const vector & a};
friend ostream & operate << (ostream & os,const vector & v);
};
}//end namespace vector
endif








Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2006-12-12 14:53
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 
再请教一下,C++什么情况下要区分大小写?
上面的更正一下头文件改为大写
#include VECTOR_H_
#include VECTOR_H_
namespace VOCTOR

Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2006-12-12 15:12
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 
?怎么没人帮帮我啊

Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2006-12-13 12:24
song4
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:38
帖 子:1533
专家分:4
注 册:2006-3-25
收藏
得分:0 
C++什么时候都区分大小写啊

嵌入式 ARM 单片机 驱动 RT操作系统 J2ME LINUX  Symbian C C++ 数据结构 JAVA Oracle 设计模式 软件工程 JSP
2006-12-13 22:17
kai
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:52
帖 子:3450
专家分:59
注 册:2004-4-25
收藏
得分:0 
yuyunliuhen,

你的这个程序正是 C++ Primer Plus 中的3个程序, 他们是
listing 11.13 vect.h
listing 11.14 vect.cpp
listing 11.15 randwalk.cpp

你只是犯了很多拼写错误而已, 建议你用emule 搜一下, 然后下载.

自由,民主,平等,博爱,进步.
中华民国,我的祖国,中华民国万岁!中华民国加油!
本人自愿加入中国国民党,为人的自由性,独立性和平等性而奋斗!
2006-12-14 10:11
kai
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:52
帖 子:3450
专家分:59
注 册:2004-4-25
收藏
得分:0 
你可以将他们
#include VECTOR_H_
#include VECTOR_H_

改为
#include vector_h_
#include vector_h_

这两个写法是同样有效的.


自由,民主,平等,博爱,进步.
中华民国,我的祖国,中华民国万岁!中华民国加油!
本人自愿加入中国国民党,为人的自由性,独立性和平等性而奋斗!
2006-12-14 10:13
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 

谢谢!
你真行啊!连出处都能指出来,看来版主都不是盖的~


Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2006-12-14 21:55
快速回复:为什么找不到执行文件?无法编译。
数据加载中...
 
   



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

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