c++成员函数后的&似然函数里的符号是什么意思思?

C++类的成员函数前加&什么意思_百度知道
C++类的成员函数前加&什么意思
在一个类的的成员函数声明时,在返回值的后面(也就是函数名的前面)加了&是什么意思??求解释下,谢谢...
在一个类的的成员函数声明时,在返回值的后面(也就是函数名的前面)加了&是什么意思??求解释下,谢谢
答题抽奖
首次认真答题后
即可获得3次抽奖机会,100%中奖。
采纳数:6184
获赞数:7966
这个和函数参数加地址符的作用是一样的,用于返值返回的是引用而不是赋值。也就是说,该函数返值会通过地址传送的方式给到函数调用者要求的返回值,这样可以节省对象赋值造成的内存浪费,通常用于返值是大型对象(而不是简单变量类型)的时候。比如你有个class T,而这个函数的返值是return T; 加上地址符返值后,返回T变量的地址,将地址传递给接收返值的变量,而不是新建一个类T,调用类的复制函数创建一个新类。
采纳数:2438
获赞数:2888
& 就是引用的意思引用就是某一变量(目标)的一个别名,对引用的操作与对变量直接操作完全一样。
为你推荐:
其他类似问题
您可能关注的内容
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。c++中是什么意思
c++中是什么意思
时间: 14:44:39
  -&在C++中是什么意思?下面是学习啦小编给大家整理的c++中是什么意思,供大家参阅!
  -&在C++中是什么意思
  -& 在c++中为取成员运算符
  对象指针/结构指针-&成员变量/成员函数
  该运算符的作用,取得指针所指向的类对象或结构变量的成员变量的值,或者调用其成员函数。
  int *p;
  struct student
  { char name[20];
  stu={xiaoming,90};
  cout&&stu.name&&stu.num&&
  cout&&p-&name&&p-&num&&
  这两个cout的效果是一样的
  ::在c++中的表示含义
  ::在c++中表示作用域,和所属关系
  class A
  public:
  int test();
  int A::test()//表示test是属于A的
  return 0;
  类似的还有其他,就不列举了
  --------------------
  void test ()
  int a = ::a;//用全局变量a,给本地变量a赋值
  c++中的宏使用
  众多C++书籍都忠告我们C语言宏是万恶之首,但事情总不如我们想象的那么坏,就如同goto一样。宏有
  一个很大的作用,就是自动为我们产生代码。如果说模板可以为我们产生各种型别的代码(型别替换),
  那么宏其实可以为我们在符号上产生新的代码(即符号替换、增加)。
  关于宏的一些语法问题,可以在google上找到。相信我,你对于宏的了解绝对没你想象的那么多。如果你
  还不知道#和##,也不知道prescan,那么你肯定对宏的了解不够。
  我稍微讲解下宏的一些语法问题(说语法问题似乎不妥,macro只与preprocessor有关,跟语义分析又无关):
  1. 宏可以像函数一样被定义,例如:
  #define min(x,y) (x&y?x:y) //事实上这个宏存在BUG
  但是在实际使用时,只有当写上min(),必须加括号,min才会被作为宏展开,否则不做任何处理。
  2. 如果宏需要参数,你可以不传,编译器会给你警告(宏参数不够),但是这会导致错误。如C++书籍中所描
  述的,编译器(预处理器)对宏的语法检查不够,所以更多的检查性工作得你自己来做。
  3. 很多程序员不知道的#和##
  #符号把一个符号直接转换为字符串,例如:
  #define STRING(x) #x
  const char *str = STRING( test_string ); str的内容就是&test_string&,也就是说#会把其后的符号
  直接加上双引号。
  ##符号会连接两个符号,从而产生新的符号(词法层次),例如:
  #define SIGN( x ) INT_##x
  int SIGN( 1 ); 宏被展开后将成为:int INT_1;
  4. 变参宏,这个比较酷,它使得你可以定义类似的宏:
  #define LOG( format, ... ) printf( format, __VA_ARGS__ )
  LOG( &%s %d&, str, count );
  __VA_ARGS__是系统预定义宏,被自动替换为参数列表。
  5. 当一个宏自己调用自己时,会发生什么?例如:
  #define TEST( x ) ( x + TEST( x ) )
  TEST( 1 ); 会发生什么?为了防止无限制递归展开,语法规定,当一个宏遇到自己时,就停止展开,也就是
  说,当对TEST( 1 )进行展开时,展开过程中又发现了一个TEST,那么就将这个TEST当作一般的符号。TEST(1)
  最终被展开为:1 + TEST( 1) 。
  6. 宏参数的prescan,
  当一个宏参数被放进宏体时,这个宏参数会首先被全部展开(有例外,见下文)。当展开后的宏参数被放进宏体时,
  预处理器对新展开的宏体进行第二次扫描,并继续展开。例如:
  #define PARAM( x ) x
  #define ADDPARAM( x ) INT_##x
  PARAM( ADDPARAM( 1 ) );
  因为ADDPARAM( 1 ) 是作为PARAM的宏参数,所以先将ADDPARAM( 1 )展开为INT_1,然后再将INT_1放进PARAM。
  例外情况是,如果PARAM宏里对宏参数使用了#或##,那么宏参数不会被展开:
  #define PARAM( x ) #x
  #define ADDPARAM( x ) INT_##x
  PARAM( ADDPARAM( 1 ) ); 将被展开为&ADDPARAM( 1 )&。
  使用这么一个规则,可以创建一个很有趣的技术:打印出一个宏被展开后的样子,这样可以方便你分析代码:
  #define TO_STRING( x ) TO_STRING1( x )
  #define TO_STRING1( x ) #x
  TO_STRING首先会将x全部展开(如果x也是一个宏的话),然后再传给TO_STRING1转换为字符串,现在你可以这样:
  const char *str = TO_STRING( PARAM( ADDPARAM( 1 ) ) );去一探PARAM展开后的样子。
  7. 一个很重要的补充:就像我在第一点说的那样,如果一个像函数的宏在使用时没有出现括号,那么预处理器只是
  将这个宏作为一般的符号处理(那就是不处理)。
  我们来见识一下宏是如何帮助我们自动产生代码的。如我所说,宏是在符号层次产生代码。我在分析Boost.Function
  模块时,因为它使用了大量的宏(宏嵌套,再嵌套),导致我压根没看明白代码。后来发现了一个小型的模板库ttl,说的
  是开发一些小型组件去取代部分Boost(这是一个好理由,因为Boost确实太大)。同样,这个库也包含了一个function库。
  这里的function也就是我之前提到的functor。ttl.function库里为了自动产生很多类似的代码,使用了一个宏:
  #define TTL_FUNC_BUILD_FUNCTOR_CALLER(n) /
  template& typename R, TTL_TPARAMS(n) & /
  struct functor_caller_base##n /
  ///...
  该宏的最终目的是:通过类似于TTL_FUNC_BUILD_FUNCTOR_CALLER(1)的调用方式,自动产生很多functor_caller_base模板:
  template &typename R, typename T1& struct functor_caller_base1
  template &typename R, typename T1, typename T2& struct functor_caller_base2
  template &typename R, typename T1, typename T2, typename T3& struct functor_caller_base3
  ///...
  那么,核心部分在于TTL_TPARAMS(n)这个宏,可以看出这个宏最终产生的是:
  typename T1
  typename T1, typename T2
  typename T1, typename T2, typename T3
  ///...
  我们不妨分析TTL_TPARAMS(n)的整个过程。分析宏主要把握我以上提到的一些要点即可。以下过程我建议你翻着ttl的代码,
  相关代码文件:function.hpp, macro_params.hpp, macro_repeat.hpp, macro_misc.hpp, macro_counter.hpp。
  so, here we Go
  分析过程,逐层分析,逐层展开,例如TTL_TPARAMS(1):
  #define TTL_TPARAMS(n) TTL_TPARAMSX(n,T)
  =& TTL_TPARAMSX( 1, T )
  #define TTL_TPARAMSX(n,t) TTL_REPEAT(n, TTL_TPARAM, TTL_TPARAM_END, t)
  =& TTL_REPEAT( 1, TTL_TPARAM, TTL_TPARAM_END, T )
  #define TTL_TPARAM(n,t) typename t##n,
  #define TTL_TPARAM_END(n,t) typename t##n
  #define TTL_REPEAT(n, m, l, p) TTL_APPEND(TTL_REPEAT_, TTL_DEC(n))(m,l,p) TTL_APPEND(TTL_LAST_REPEAT_,n)(l,p)
  注意,TTL_TPARAM, TTL_TPARAM_END虽然也是两个宏,他们被作为TTL_REPEAT宏的参数,按照prescan规则,似乎应该先将
  这两个宏展开再传给TTL_REPEAT。但是,如同我在前面重点提到的,这两个宏是function-like macro,使用时需要加括号,
  如果没加括号,则不当作宏处理。因此,展开TTL_REPEAT时,应该为:
  =& TTL_APPEND( TTL_REPEAT_, TTL_DEC(1))(TTL_TPARAM,TTL_TPARAM_END,T) TTL_APPEND( TTL_LAST_REPEAT_,1)(
  TTL_TPARAM_END,T)
  这个宏体看起来很复杂,仔细分析下,可以分为两部分:
  TTL_APPEND( TTL_REPEAT_, TTL_DEC(1))(TTL_TPARAM,TTL_TPARAM_END,T)以及
  TTL_APPEND( TTL_LAST_REPEAT_,1)(TTL_TPARAM_END,T)
  先分析第一部分:
  #define TTL_APPEND( x, y ) TTL_APPEND1(x,y) //先展开x,y再将x,y连接起来
  #define TTL_APPEND1( x, y ) x ## y
  #define TTL_DEC(n) TTL_APPEND(TTL_CNTDEC_, n)
  根据先展开参数的原则,会先展开TTL_DEC(1)
  =& TTL_APPEND(TTL_CNTDEC_,1) =& TTL_CNTDEC_1
  #define TTL_CNTDEC_1 0 注意,TTL_CNTDEC_不是宏,TTL_CNTDEC_1是一个宏。
  =& 0 , 也就是说,TTL_DEC(1)最终被展开为0。回到TTL_APPEND部分:
  =& TTL_REPEAT_0 (TTL_TPARAM,TTL_TPARAM_END,T)
  #define TTL_REPEAT_0(m,l,p)
  TTL_REPEAT_0这个宏为空,那么,上面说的第一部分被忽略,现在只剩下第二部分:
  TTL_APPEND( TTL_LAST_REPEAT_,1)(TTL_TPARAM_END,T)
  =& TTL_LAST_REPEAT_1 (TTL_TPARAM_END,T) // TTL_APPEND将TTL_LAST_REPEAT_和1合并起来
  #define TTL_LAST_REPEAT_1(m,p) m(1,p)
  =& TTL_TPARAM_END( 1, T )
  #define TTL_TPARAM_END(n,t) typename t##n
  =& typename T1 展开完毕。
  虽然我们分析出来了,但是这其实并不是我们想要的。我们应该从那些宏里去获取作者关于宏的编程思想。很好地使用宏
  看上去似乎是一些偏门的奇技淫巧,但是他确实可以让我们编码更自动化。
看过c++中是什么意思的人还看了:
[c++中是什么意思]相关的文章
【英语其它】图文推荐在C++里,什么是类的数据成员?什么是类的成员函数?_百度知道
在C++里,什么是类的数据成员?什么是类的成员函数?
采纳数:49
获赞数:181
类的数据成员:就是类中的一个实例变量类的成员函数:就i是类中的一个实例函数class demo{public :void print();//类的成员函数//类的数据成员};希望对你有用...
为你推荐:
其他类似问题
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。c++如下定义类函数后加冒号是什么意思 什么时候这么用_百度知道
c++如下定义类函数后加冒号是什么意思 什么时候这么用
如M(constchar*in_file):m_w(),m_object_morph(true)...
如 M( const char* in_file ):m_w(),m_object_morph(true)
答题抽奖
首次认真答题后
即可获得3次抽奖机会,100%中奖。
来自科学教育类芝麻团
采纳数:260
获赞数:2497
参与团队:
c++如下定义类函数后加冒号是表示函数属于这个类,类的成员函数定义在类外面的时候需要这么用。类的成员函数描述的是类的行为,是程序算法的实现部分,是对封装的数据进行操作的方法。类的成员函数的原型要写在类体中,原型说明了函数的参数表和返回值类型。而函数的定义一般在类外面,也可以直接在类内部定义。前者与普通函数不同的是,实现成员函数时要指明类的名称,具体形式为:返回值类型 类名 ::函数成员名(参数表){函数体};而后者一般为一些短小的函数(5行以内),也就是内联函数。示例:class Student{
void display( );
//公用成员函数原型声明
//以上3行是私有数据成员};void Student∷display( )//在类外定义display类函数{
cout&&″num:″&&num&&
cout&&″name:″&&name&&
cout&&″sex:″&&sex&&}
longmarchw
longmarchw
采纳数:41
获赞数:275
这是对类成员初始化的意思,一般用于对父类成员初始化。
跟写在程序体里有什么区别呢
如果子类中有无参构造函数而而父类中没有声明,则程序会无法通过编译。举例如下:#include &stdafx.h&class testP{public: int t1; int t2;public: //testP(int t = 1){}
//正确 testP(int t){} testP(const testP&t ){}
//没有const也可以通过编译,在C++PRIMER中说“传统上我们声明为const”p584(14-2-3节。) void set(){};//注意这个分号,包括CPP中函数后加上,他不代表类中的函数可以跟一个分号,而是代表一个空语句。};class testStatic:public testP{public: testStatic():testP(1){}//正确:在这里虽然找不到父类无参构造函数,但公开声明了一个带参函数 static void test(); void nonstatic();public:};int testStatic::t = 0;void testStatic::test(){
}void testStatic::nonstatic(){ test();}int main(int argc, char* argv[]){ testStatic::test(); testS t.set(); printf(&Hello World!\n&); return 0;}2、拷贝构造函数的定义方法 testP(const testP&t ){}
拷贝函数应该这样定义,虽然没有CONST也是可以通过编译的。但不推荐那样做,因为做为拷贝函数,你首先要保证被复制者不能改变,也就是说不能在复制过程中改变,所以要加上CONST。3、冒号的错误理解:void set(){};象这样我们在一个函数后面加一个分号,或者在把成员函数直接定义在类头文件里时,加上一个分号,不代表函数后面可以任意有无一个分号,而是那个分号代表这是一条空语句。
本回答被提问者采纳
guoneng_wei
guoneng_wei
采纳数:385
获赞数:1950
如 M( const char* in_file ):m_w(),m_object_morph(true):意思是,在调用M( const char* in_file )函数之前,先调用冒号后面的两个函数,m_w()和m_object_morph(true)。
跟写在程序体里有什么区别呢
从效果上来说,没什么区别。只是有些时候规定要写在冒号后面,比如继承类的初始化。同时,让人明白这是有特殊用途的,不像写在方法体里面那样的普通。
》比如继承类的初始化 能给举个这种例子吗?
采纳数:371
获赞数:867
初始化表,构造函数后声明,用于初始化基类的成员
跟写在程序体里有什么区别呢
这是一个设计模式的问题,基类是一个抽象,比如动物,而派生类可以是更具体的抽象如猫,狗,在抽象动物这个类的时候你显然要构建基础通用的特性,如成员腿(UINT),但你不知道具体对象腿有多少个,派生类(猫)有4条腿,这个时候需要初始化基类的腿的个数,就会用到这个初始化表了,你不可能去修改基类的构造函数,当然,你也可以在派生类的某个方法函数中去修改他,但这种我们习惯在构造函数中确定。
AllenBarrykin
AllenBarrykin
擅长:暂未定制
对对象的默认初始化,赋值!
1条折叠回答
其他2条回答
为你推荐:
其他类似问题
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。24小时热门版块排行榜&&&&
【悬赏金币】回答本帖问题,作者zhangguoli13将赠送您 10 个金币
(小有名气)
在线: 340.8小时
虫号: 2242813
注册: 性别: GG专业: 机械测试理论与技术
c++头文件中已经定义的函数,实现时提示不是类的成员函数已有1人参与
这是头文件
# include &Grids.hpp&//StringGrid
# include &Sysdefs.h&//AnsiString
# include &fstream&//ifstream ofstream
/*地质库*/
#ifndef GEOLOGY
#define GEOLOGY
/*地质库数据*/
struct geoldata
& & & & AnsiS//地址类型名称
& & & & float E;//土体弹性模量
& & & &//土体泊松比
& & & &//土体容重
& & & &//土体粘聚力
& & & & float K0;//土体静土压力系数
& & & &//土体摩擦角
& & & & float f[5];//土体摩擦系数
/*地质库类*/
class geology
& & & & protected:
& & & & & & & &//地质库地址类型个数,0为空状态
& & & & & & & &//数据是否被检查过
& & & & & & & & geoldata *//地址类型构架指针,动态内存分配,顺序线性表,简单数组
& & & & public:
& & & & & & & & geology();//无参构造
& & & & & & & & geology(geology const &geol);//拷贝构造,主要处理指针成员
& & & & & & & & ~geology();//析构,注意释放空间
& & & & & & & & geology operator=(const geology &geol);//重载=,作用类似拷贝构造函数
& & & & & & & & bool add(AnsiString iname,float iE,float imu,float igamma,float ic,float iK_0,float iphi,float if1,float if2,float if3,float if4,float if5);//添加
& & & & & & & & bool set(AnsiString iname,float iE,float imu,float igamma,float ic,float iK_0,float iphi,float if1,float if2,float if3,float if4,float if5,bool change);//更改
& & & & & & & & bool dele(int num);//删除指定标号,如果已经为空,注意释放空间
& & & & & & & & bool empty();//清空,注意释放空间
& & & & & & & & bool iswrong(int *num,int *var,AnsiString *reason);//检查错误,有错返回true,并将标号、变量、原因写入相应指针指定数组
& & & & & & & & int getcount();//返回count
& & & & & & & & int getnum(AnsiString findname);//查找地质库名称返回标号
& & & & & & & & geoldata get(int num);//返回相应地质库数据
& & & & & & & & bool gridout(TStringGrid *StringGrid);//将数据打印在StringGrid上
& & & & & & & & bool gridout(TStringGrid *StringGrid,AnsiString findname,int row);//将相应数据打印StringGrid在指定行上
& & & & & & & & bool excelread(Variant Sheet);//从excel导入,empty决定是否追加
& & & & & & & & bool excelwrite(Variant Sheet);//导出到excel
& & & & & & & & bool binread(std::ifstream &infile);//从二进制文件导入,empty决定是否追加
& & & & & & & & bool binwrite(std::ofstream &outfile);//保存为二进制文件
下面是类的实现
# include &Grids.hpp&//StringGrid
# include &Sysdefs.h&//AnsiString
# include &fstream&//ifstream ofstream
# include &Comobj.hpp&
# include &geology.h&
/************************************************************************/
geology::geology():count(0),ischeck(false),data(NULL){}
/************************************************************************/
geology::geology(geology const &geol)
& && &&&if(geol.count==0)
& && && && && & data=NULL;
& && &&&else
& && && && && & data=new geoldata[geol.count];
& && && && && & for(int i=0;i&geol.i++)
& && && && && & {
& && && && && && && && &data.name=geol.data.
& && && && && && && && &data.E=geol.data.E;
& && && && && && && && &data.mu=geol.data.
& && && && && && && && &data.gamma=geol.data.
& && && && && && && && &data.c=geol.data.c;
& && && && && && && && &data.K0=geol.data.K0;
& && && && && && && && &data.phi=geol.data.
& && && && && && && && &data.f[0]=geol.data.f[0];
& && && && && && && && &data.f[1]=geol.data.f[1];
& && && && && && && && &data.f[2]=geol.data.f[2];
& && && && && && && && &data.f[3]=geol.data.f[3];
& && && && && && && && &data.f[4]=geol.data.f[4];
& && && && && & }
& && &&&count=geol.
& && &&&ischeck=geol.
/************************************************************************/
geology::~geology()
& && &&&if(data!=NULL)
& && &&&delete []
/************************************************************************/
geology geology::operator=(const geology &geol)
& && &&&if(this==&geol)
& && && && && & return *
& && &&&if(count!=0)
& && && && && & delete []
& && &&&count=geol.
& && &&&ischeck=geol.
& && &&&if(count==0)
& && && && && & return *
& && &&&data=new geoldata[geol.count];
& && &&&for(int i=0;i&geol.i++)
& && && && && & data.name=geol.data.
& && && && && & data.E=geol.data.E;
& && && && && & data.mu=geol.data.
& && && && && & data.gamma=geol.data.
& && && && && & data.c=geol.data.c;
& && && && && & data.K0=geol.data.K0;
& && && && && & data.phi=geol.data.
& && && && && & data.f[0]=geol.data.f[0];
& && && && && & data.f[1]=geol.data.f[1];
& && && && && & data.f[2]=geol.data.f[2];
& && && && && & data.f[3]=geol.data.f[3];
& && && && && & data.f[4]=geol.data.f[4];
& && &&&return *
/************************************************************************/
bool geology::add(AnsiString iname,float iE,float imu,float igamma,float ic,float iK_0,float iphi,float if1,float if2,float if3,float if4,float if5)
& & & & geoldata *
& & & & temp=new geoldata[count+2];
& && & & & & & if(count==0)
& & & & & & & & temp[count].name=
& & & & & & & & temp[count].E=iE;
& & & & & & & & temp[count].mu=
& & & & & & & & temp[count].gamma=
& & & & & & & & temp[count].c=
& & & & & & & & temp[count].K0=iK_0;
& & & & & & & & temp[count].phi=
& & & & & & & & temp[count].f[0]=if1;
& & & & & & & & temp[count].f[1]=if2;
& & & & & & & & temp[count].f[2]=if3;
& & & & & & & & temp[count].f[3]=if4;
& & & & & & & & temp[count].f[4]=if5;
& && && && && & data=
& & & && && && &count++;
& & & && && && &
& && &&&for(int i=0;i&i++)
& && && && && & if(data.name==iname)
& && && && && &
& & & & for(int i=0;i&i++)
& && & & & & & & & & & temp.name=data.
& && & & & & & & & & & temp.E=data.E;
& && & & & & & & & & & temp.mu=data.
& && & & & & & & & & & temp.gamma=data.
& && & & & & & & & & & temp.c=data.c;
& && & & & & & & & & & temp.K0=data.K0;
& && & & & & & & & & & temp.phi=data.
& && & & & & & & & & & temp.f[0]=data.f[0];
& && & & & & & & & & & temp.f[1]=data.f[1];
& && & & & & & & & & & temp.f[2]=data.f[2];
& && & & & & & & & & & temp.f[3]=data.f[3];
& && & & & & & & & & & temp.f[4]=data.f[4];
& && & & & & & }
& & & & temp[count].name=
& & & & temp[count].E=iE;
& & & & temp[count].mu=
& & & & temp[count].gamma=
& & & & temp[count].c=
& & & & temp[count].K0=iK_0;
& & & & temp[count].phi=
& & & & temp[count].f[0]=if1;
& && & & & & & temp[count].f[1]=if2;
& && & & & & & temp[count].f[2]=if3;
& && & & & & & temp[count].f[3]=if4;
& && & & & & & temp[count].f[4]=if5;
& & & & data=
& & & & count++;
& && &&&ischeck=
/************************************************************************/
bool geology::set(AnsiString iname,float iE,float imu,float igamma,float ic,float iK_0,float iphi,float if1,float if2,float if3,float if4,float if5,bool change)
& && &&&for(int i=0;i&i++)
& && && && && & if(data.name.AnsiCompare(iname)==0)
& && && && && & {
& && && && && && && && &data.name=
& && && && && && && && &data.E=iE;
& & & && && && && && &&&data.mu=
& & & && && && && && &&&data.gamma=
& & & && && && && && &&&data.c=
& & & && && && && && &&&data.K0=iK_0;
& & & && && && && && &&&data.phi=
& & & && && && && && &&&data.f[0]=if1;
& && & & & & && && && && && &&&data.f[1]=if2;
& && & & & & && && && && && &&&data.f[2]=if3;
& && & & & & && && && && && &&&data.f[3]=if4;
& && & & & & && && && && && &&&data.f[4]=if5;
& && && && && && && && &ischeck=
& && && && && && && && &
& && && && && & }
/************************************************************************/
bool geology::dele(int num)
& & & & if(num&=0&&num&=count-1)
& && && && && & for(int i=i&count-1;i++)
& && && && && & {
& && && && && && && && &data.name=data[i+1].
& & & && && &&&& & & && && && &data.E=data[i+1].E;
& & & && && && && & & & data.mu=data[i+1].
& & & && && && & & && && && &data.gamma=data[i+1].
& & & && &&&& & & && && && &data.c=data[i+1].c;
& & & && & & & & && && && &data.K0=data[i+1].K0;
& & & && && && && & & & data.phi=data[i+1].
& & & &&&& & & && && && &data.f[0]=data[i+1].f[0];
& & & && && && && & & & data.f[1]=data[i+1].f[1];
& && & & & & & & & & && && && &data.f[2]=data[i+1].f[2];
& && && & & && && && && & & & data.f[3]=data[i+1].f[3];
& &&&& & & & & & & && && && &data.f[4]=data[i+1].f[4];
& & & & & && && && &}
& && && && && & delete &data[count-1];
& && && && && & //&data[count-1]=NULL;& && &&&//这个指针付null时为什么有错误呢?
& && & & && && && &count--;
&&& & & && && && &
/************************************************************************/
bool geology::empty()
& && &&&if(count==0)
& & & & delete []
& && &&&data=NULL;& && && && & //我试过了,data不会自动为空。
& & & & count=0;
& && &&&ischeck=
/************************************************************************/
bool geology::iswrong(int *num,int *var,AnsiString *reason)
& && &&&/*1.name为空;
& && &&&2.弹性模量,土体容重,土体黏聚力,摩擦系数,土体静土压力系数大于0
& && &&&3.泊松比0~0.5;
& && &&&4。土体摩擦角0~180.
& && &&&5.12个参数任意一个为空时
& && &&&*/
/************************************************************************/
int geology::getcount()
/************************************************************************/
int geology::getnum(AnsiString findname)
& && &&&for(int i=0;i&i++)
& && && && && & if(data.name.AnsiCompare(findname)==0)
& && && && && &
& && &&&return -1;
/************************************************************************/
geoldata geology::get(int num)
& && &&&temp.name=&&;
& && &&&if(num&=0&&num&count)
& && &&&return this-&data[num];
& && &&&& && && && && && && &
/************************************************************************/
bool geology::gridout(TStringGrid *StringGrid)
& && &&&int fixr,fixc,sr,
& && &&&fixr=StringGrid-&FixedR
& && &&&//fixc=StringGrid-&FixedC
& && &&&sr=StringGrid-&RowC
& && &&&sc=StringGrid-&ColC
& && &&&//if(sr&(count+fixr)|sc&12)& & //Stringgrid行数或列数太少时返回
& && && && &&&//&&
& && &&&if(sc&12)& && && && && && && & //stringgrid只有列数太少时返回。
& && && && && &
& && &&&for(int i=0;i&i++)
& && && && && & if(i&sr)& && && && &&&//判断是否超出了stringgrid的行数,如果超出则不再打印
& && && && && & {
& && && && && & StringGrid-&Cells[0][i+fixr]=data.
& && && && && & StringGrid-&Cells[1][i+fixr]=data.E;
& && && && && & StringGrid-&Cells[2][i+fixr]=data.
& && && && && & StringGrid-&Cells[3][i+fixr]=data.
& && && && && & StringGrid-&Cells[4][i+fixr]=data.c;
& && && && && & StringGrid-&Cells[5][i+fixr]=data.K0;
& && && && && & StringGrid-&Cells[6][i+fixr]=data.
& && && && && & StringGrid-&Cells[7][i+fixr]=data.f[0];
& && && && && & StringGrid-&Cells[8][i+fixr]=data.f[1];
& && && && && & StringGrid-&Cells[9][i+fixr]=data.f[2];
& && && && && & StringGrid-&Cells[10][i+fixr]=data.f[3];
& && && && && & StringGrid-&Cells[11][i+fixr]=data.f[4];
& && && && && & }
/************************************************************************/
bool geology::gridout(TStringGrid *StringGrid,AnsiString findname,int row)
& && &&&int fixr,fixc,sr,sc,r;
& && &&&fixr=StringGrid-&FixedR
& && &&&//fixc=StringGrid-&FixedC
& && &&&sr=StringGrid-&RowC
& && &&&//sc=StringGrid-&ColC
& && &&&r=row+
& && &&&//if(sr&(count+fixr)|sc&12)
& && && &//& && &
& && &&&for(int i=0;i&i++)
& && && && && & if(data.name.AnsiCompare(findname)==0&&row&=1&&row&=sr)& && &//row的取值范围为1~sr.
& && && && && & {
& && && && && && && && &StringGrid-&Cells[0][r-1]=data.
& && && && && && && && &StringGrid-&Cells[1][r-1]=data.E;
& && && && && && && && &StringGrid-&Cells[2][r-1]=data.
& && && && && && && && &StringGrid-&Cells[3][r-1]=data.
& && && && && && && && &StringGrid-&Cells[4][r-1]=data.c;
& && && && && && && && &StringGrid-&Cells[5][r-1]=data.K0;
& && && && && && && && &StringGrid-&Cells[6][r-1]=data.
& && && && && && && && &StringGrid-&Cells[7][r-1]=data.f[0];
& && && && && && && && &StringGrid-&Cells[8][r-1]=data.f[1];
& && && && && && && && &StringGrid-&Cells[9][r-1]=data.f[2];
& && && && && && && && &StringGrid-&Cells[10][r-1]=data.f[3];
& && && && && && && && &StringGrid-&Cells[11][r-1]=data.f[4];
& && && && && && && && &
& && && && && & }
/************************************************************************/
bool geology::excelread(Variant Sheet)
& && &&&int HANG,LIE,i(2),j(1);
& && &&&if(count!=0)
& && && && && & delete []
& && && && && & count=0;
& && &&&while(!(Sheet.OlePropertyGet(&Cells&, i, 1).OlePropertyGet(&Value&)).IsEmpty())
& && && && && & HANG=i-1;
& && && && && & i++;
& && &&&while(!(Sheet.OlePropertyGet(&Cells&, 1, j).OlePropertyGet(&Value&)).IsEmpty())
& && && && && & LIE=j;
& && && && && & j++;
& && & if(!(LIE==12|LIE==0))
& && &&&{& && && && && && && && && && && && && && && && && && && && && && && &&&
& && && && && & //ShowMessage(&导入文件不符合规定,请重新选择&);
& && && && && &
& && &&&for(i=2;i&=HANG+1;i++)
& & & & & & & & AnsiString iname=Sheet.OlePropertyGet(&Cells&, i, 1).OlePropertyGet(&Value&);
& && && && && & float iE=StrToFloat(Sheet.OlePropertyGet(&Cells&, i, 2).OlePropertyGet(&Value&));
& && && && && & float imu=StrToFloat(Sheet.OlePropertyGet(&Cells&, i, 3).OlePropertyGet(&Value&));
& && && && && & float igamma=StrToFloat(Sheet.OlePropertyGet(&Cells&, i, 4).OlePropertyGet(&Value&));
& && && && && & float ic=StrToFloat(Sheet.OlePropertyGet(&Cells&, i, 5).OlePropertyGet(&Value&));
& && && && && & float iK_0=StrToFloat(Sheet.OlePropertyGet(&Cells&, i, 6).OlePropertyGet(&Value&));
& && && && && & float iphi=StrToFloat(Sheet.OlePropertyGet(&Cells&, i, 7).OlePropertyGet(&Value&));
& && && && && & float if1=StrToFloat(Sheet.OlePropertyGet(&Cells&, i, 8).OlePropertyGet(&Value&));
& && && && && & float if2=StrToFloat(Sheet.OlePropertyGet(&Cells&, i, 9).OlePropertyGet(&Value&));
& && && && && & float if3=StrToFloat(Sheet.OlePropertyGet(&Cells&, i, 10).OlePropertyGet(&Value&));
& && && && && & float if4=StrToFloat(Sheet.OlePropertyGet(&Cells&, i, 11).OlePropertyGet(&Value&));
& && && && && & float if5=StrToFloat(Sheet.OlePropertyGet(&Cells&, i, 12).OlePropertyGet(&Value&));
& & & & & & & & add(iname,iE,imu,igamma,ic,iK_0,iphi,if1,if2,if3,if4,if5);
/************************************************************************/
bool geology::excelwrite(Variant Sheet)
& && &&&Sheet.OlePropertyGet(&Cells&, 1, 1).OlePropertySet(&Value&, &地址类型名称&);
& && &&&Sheet.OlePropertyGet(&Cells&, 1, 2).OlePropertySet(&Value&, &土体弹性模量&);
& && &&&Sheet.OlePropertyGet(&Cells&, 1, 3).OlePropertySet(&Value&, &土体泊松比&);
& && &&&Sheet.OlePropertyGet(&Cells&, 1, 4).OlePropertySet(&Value&, &土体容重&);
& && &&&Sheet.OlePropertyGet(&Cells&, 1, 5).OlePropertySet(&Value&, &土体粘聚力&);
& && &&&Sheet.OlePropertyGet(&Cells&, 1, 6).OlePropertySet(&Value&, &土体静土压力系数&);
& && &&&Sheet.OlePropertyGet(&Cells&, 1, 7).OlePropertySet(&Value&, &土体摩擦角&);
& && &&&Sheet.OlePropertyGet(&Cells&, 1, 8).OlePropertySet(&Value&, &土体摩擦系数1&);
& && &&&Sheet.OlePropertyGet(&Cells&, 1, 9).OlePropertySet(&Value&, &土体摩擦系数2&);
& && &&&Sheet.OlePropertyGet(&Cells&, 1, 10).OlePropertySet(&Value&, &土体摩擦系数3&);
& && &&&Sheet.OlePropertyGet(&Cells&, 1, 11).OlePropertySet(&Value&, &土体摩擦系数4&);
& && &&&Sheet.OlePropertyGet(&Cells&, 1, 12).OlePropertySet(&Value&, &土体摩擦系数5&);
& && &&&for(int i=2;i&count+2;i++)
& && && && && & Sheet.OlePropertyGet(&Cells&, i, 1).OlePropertySet(&Value&, WideString(data[i-2].name));
& && && && && & Sheet.OlePropertyGet(&Cells&, i, 2).OlePropertySet(&Value&, data[i-2].E);
& && && && && & Sheet.OlePropertyGet(&Cells&, i, 3).OlePropertySet(&Value&, data[i-2].mu);
& && && && && & Sheet.OlePropertyGet(&Cells&, i, 4).OlePropertySet(&Value&, data[i-2].gamma);
& && && && && & Sheet.OlePropertyGet(&Cells&, i, 5).OlePropertySet(&Value&, data[i-2].c);
& && && && && & Sheet.OlePropertyGet(&Cells&, i, 6).OlePropertySet(&Value&, data[i-2].K0);
& && && && && & Sheet.OlePropertyGet(&Cells&, i, 7).OlePropertySet(&Value&, data[i-2].phi);
& && && && && & Sheet.OlePropertyGet(&Cells&, i, 8).OlePropertySet(&Value&, data[i-2].f[0]);
& && && && && & Sheet.OlePropertyGet(&Cells&, i, 9).OlePropertySet(&Value&, data[i-2].f[1]);
& && && && && & Sheet.OlePropertyGet(&Cells&, i, 10).OlePropertySet(&Value&, data[i-2].f[2]);
& && && && && & Sheet.OlePropertyGet(&Cells&, i, 11).OlePropertySet(&Value&, data[i-2].f[3]);
& && && && && & Sheet.OlePropertyGet(&Cells&, i, 12).OlePropertySet(&Value&, data[i-2].f[4]);
/************************************************************************/
bool geology::binread(std::ifstream &infile)
& && &&&if(!infile)
& && && && && & //ShowMessage(&打开出错!&);
& && && && && &
& && &&&for(int i=0;i&i++)
& && && && && & infile.read((char *)&data,sizeof(data));
& && &&&infile.read((char *)&count,sizeof(count));
& && &&&infile.read((char *)&ischeck,sizeof(ischeck));
& && &&&infile.close();
/************************************************************************/
bool geology::binwrite(std::ofstream &outfile)
& && &&&for(int i=0;i&i++)
& && && && && & outfile.write((char *)&data,sizeof(data));
& && &&&outfile.write((char *)&count,sizeof(count));
& && &&&outfile.write((char *)&ischeck,sizeof(ischeck));
& && &&&outfile.close();
主要是set函数,运行时提示不是成员函数
& 猜你喜欢
已经有8人回复
已经有9人回复
已经有100人回复
已经有16人回复
已经有6人回复
已经有7人回复
已经有29人回复
已经有29人回复
已经有7人回复
已经有5人回复
& 本主题相关价值贴推荐,对您同样有帮助:
已经有7人回复
已经有13人回复
(小有名气)
在线: 192.2小时
虫号: 1017040
注册: 专业: 流体力学
【答案】应助回帖
感谢参与,应助指数 +1
我的经验是调用格式不对吧。你具体的调用形式是什么样子呢?是不是少写了参数什么的或者没有使用限定符、
相关版块跳转
第一性原理
我要订阅楼主
的主题更新
小木虫,学术科研互动社区,为中国学术科研免费提供动力
违规贴举报删除请发送邮件至:
广告投放与宣传请联系 李想 QQ:
QQ:&&邮箱:
Copyright &
MuChong.com, All Rights Reserved. 小木虫 版权所有

我要回帖

更多关于 对数函数公式 的文章

 

随机推荐