小编Jay*_*ers的帖子

将函数应用于数组中的每个元素

我正在编写一个c ++程序,它从文本文件中读取双打列表并将它们存储在一个数组中.我想将一个函数逐个应用于数组中的每个double,并测试结果.做这个的最好方式是什么?

c++ arrays function std

2
推荐指数
1
解决办法
685
查看次数

c ++程序返回默认值0

我写完这个初学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)

c++ class object

0
推荐指数
1
解决办法
106
查看次数

标签 统计

c++ ×2

arrays ×1

class ×1

function ×1

object ×1

std ×1