📄 root.cpp
字号:
// root.cpp: implementation of the root class.
//
//////////////////////////////////////////////////////////////////////
#include "root.h"
#include <iostream>
#include <string>
using namespace std;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
root::root()
{
}
root::~root()
{
}
//////////////////////////////////////////////////////////////////////
// accessor functions
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// getRoot
//
// parameters: int - which root (0 or 1)
// return type: complex - complex value of root
//////////////////////////////////////////////////////////////////////
complex root::getRoot(int value)
{
return roots[value];
}
//////////////////////////////////////////////////////////////////////
// getNumRoots
//
// parameters: none
// return type: int - number of roots
//////////////////////////////////////////////////////////////////////
int root::getNumRoots()
{
return (numRoots);
}
//////////////////////////////////////////////////////////////////////
// getMsg
//
// parameters: none
// return type: enumerated message (text)
//////////////////////////////////////////////////////////////////////
string root::getMsg()
{
return message;
}
//////////////////////////////////////////////////////////////////////
// setMsg
//
// parameters: rootType - enumerated message
// return type: none
//////////////////////////////////////////////////////////////////////
void root::setMsg(string msg)
{
message = msg;
}
//////////////////////////////////////////////////////////////////////
// setNumRoots
//
// parameters: int - number of roots
// return type: none
//////////////////////////////////////////////////////////////////////
void root::setNumRoots(int value)
{
numRoots=value;
}
//////////////////////////////////////////////////////////////////////
// setRoot
//
// takes int value to identify which root is to be set and a
// complex object to assign to root
//
// parameters: int, complex
// return type: complex - complex value of root
//////////////////////////////////////////////////////////////////////
void root::setRoot(int value, complex cplx)
{
roots[value] = cplx;
}
//////////////////////////////////////////////////////////////////////
// print
//
// outputs message reflecting type of root(s) and then outputs roots
//
// parameters: none
// return type: none
//////////////////////////////////////////////////////////////////////
void root::print()
{
int i;
// const char *mess[]={"two_roots","single_root", "complex_roots"};
// cout<<message<<endl;
for (i=0;i<numRoots;i++)
{
roots[i].print();
cout<<endl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -