当前位置: 首页>>代码示例>>C++>>正文


C++ Complex::get_a方法代码示例

本文整理汇总了C++中Complex::get_a方法的典型用法代码示例。如果您正苦于以下问题:C++ Complex::get_a方法的具体用法?C++ Complex::get_a怎么用?C++ Complex::get_a使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Complex的用法示例。


在下文中一共展示了Complex::get_a方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: multiply

 Complex Complex::multiply(Complex comp2)
 {
     // Following formula (a + ib ) * ( c + id ) = ( a * c - b * d ) + i( a * d + b * c )
     // Create Complex object called "temp"
     Complex temp;
     
     // Set temp data member "a" to (this->get_a() * comp2.get_a()) - (this->get_b() * comp2.get_b())
     temp.set_a((this->get_a() * comp2.get_a()) - (this->get_b() * comp2.get_b()));
     
     // Set temp data member "b" to ((this->get_a() * comp2.get_b()) + (this->get_b() * comp2.get_a()))
     temp.set_b((this->get_a() * comp2.get_b()) + (this->get_b() * comp2.get_a()));
     
     // Return resulting Complex object "temp"
     return temp;
 }
开发者ID:JohnMessina,项目名称:CSM10B,代码行数:15,代码来源:complex.cpp

示例2: isEqual

 bool Complex::isEqual(Complex comp2)
 {
     if (this->get_a() == comp2.get_a() && this->get_b() == comp2.get_b())
         return true;
     else
         return false;
 }
开发者ID:JohnMessina,项目名称:CSM10B,代码行数:7,代码来源:complex.cpp

示例3: divide

 Complex Complex::divide(Complex comp2)
 {
     /* Following formula
     
      a + ib     ( a * c + b * d )     i( c * b - a * d )
      ------ =   -----------------  +  -------------------
      c + id       c^2 + d^2                    c^2 + d^2
      
     */
     // Create Complex object called "temp"
     Complex temp;
     
     // Set temp data member "a" to ((a*c) + (b*d)) / (c^2 + d^2)
     temp.set_a((this->get_a()*comp2.get_a() + this->get_b()*comp2.get_b()) / (comp2.get_a()*comp2.get_a() + comp2.get_b()*comp2.get_b()));
     
     // Set temp data member "b" to ((c*b) - (a*d)) / (c^2 + d^2)
     temp.set_b((comp2.get_a()*this->get_b() - this->get_a()*comp2.get_b()) / (comp2.get_a()*comp2.get_a() + comp2.get_b()*comp2.get_b()));
     
     return temp;
 }
开发者ID:JohnMessina,项目名称:CSM10B,代码行数:20,代码来源:complex.cpp

示例4: subtract

 Complex Complex::subtract(Complex comp2)
 {
     // Following formula ( a + ib ) - ( c + id ) = ( a - c ) + i( b - d )
     // Create Complex object called "temp"
     Complex temp;
     
     // Set temp data member "a" to difference of local "a" and parameter comp2's "a"
     temp.set_a((this->get_a()) - (comp2.get_a()));
     
     // Set temp data member "b" to difference local "b" and parameter comp2's "b"
     temp.set_b((this->get_b()) - (comp2.get_b()));
     
     // Return resulting Complex object "temp"
     return temp;
 }
开发者ID:JohnMessina,项目名称:CSM10B,代码行数:15,代码来源:complex.cpp

示例5: add

 // function to add 2 complex numbers
 Complex Complex::add(Complex comp2)
 {
     // Following formula ( a + ib ) + ( c + id ) = ( a + c ) + i( b + d )
     // Create Complex object called "temp"
     Complex temp;
     
     // Set temp data member "a" to sum of local "a" and parameter comp2's "a"
     temp.set_a((this->get_a()) + (comp2.get_a()));
     
     // Set temp data member "b" to sum of local "b" and parameter comp2's "b"
     temp.set_b((this->get_b()) + (comp2.get_b()));
     
     // Return resulting Complex object "temp"
     return temp;
 }
开发者ID:JohnMessina,项目名称:CSM10B,代码行数:16,代码来源:complex.cpp


注:本文中的Complex::get_a方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。