小编Sta*_*rst的帖子

一个班级的私人功能可以访问?

我一直在努力学习C++.最近我遇到了以下代码:

#include <iostream>

using namespace std;

class Point {
    private:
        double x_, y_;

    public: 
        Point(double x, double y){
            x_ = x;
            y_ = y; 
        }

        Point() {
            x_ = 0.0;
            y_ = 0.0;   
        }

        double getX(){
            return x_;  
        }

        double getY(){
            return y_;  
        }

        void setX(double x){
            x_ = x; 
        }

        void setY(double y){
            y_ = y; 
        }

        void add(Point p){
            x_ += p.x_;
            y_ += p.y_;
        }

        void sub(Point p){
            x_ -= p.x_;
            y_ -= p.y_;
        }

        void mul(double …
Run Code Online (Sandbox Code Playgroud)

c++ oop gcc information-hiding class

4
推荐指数
2
解决办法
840
查看次数

标签 统计

c++ ×1

class ×1

gcc ×1

information-hiding ×1

oop ×1