我正在编写一个c ++程序,它从文本文件中读取双打列表并将它们存储在一个数组中.我想将一个函数逐个应用于数组中的每个double,并测试结果.做这个的最好方式是什么?
我写完这个初学c ++程序,基本上只是一个矩形类.程序编译得很好,我遇到的唯一问题是它为宽度返回零,我无法弄清楚原因.如果有人能告诉我哪里出错了并帮助我,我真的很感激.
#pragma once
class theRectangle
{
private:
int height;
int width;
public:
theRectangle();
theRectangle(int _height, int _width);
int calcArea() const;
int calcPerimeter() const;
bool is_Square()const;
int Get_Height() const;
void Set_Height(int _hight);
int Get_Width() const;
void Set_Width(int _width);
};
#include "theRectangle.h"
#include <iostream>
using namespace std;
//default constructor
theRectangle::theRectangle()
{
height = 0;
width = 0;
}
//parameterized constructor
theRectangle::theRectangle(int _height, int _width)
{
height = _height;
width = _width;
}
//get height function
int theRectangle::Get_Height() const
{
return height; …
Run Code Online (Sandbox Code Playgroud)