#ifndef MYTIME_H
#define MYTIME_H class MyTime
{
private:
int m_hour;
int m_minute;
public:
MyTime(int hour,int minute=);
~MyTime(); MyTime operator+(const MyTime & time) const;
void Show(); //int GetHour() const;
//int GetMinute() const;
}; #endif
#include "MyTime.h"
#include <iostream> MyTime::MyTime(int hour,int minute)
{
m_hour=hour;
m_minute=minute;
}; MyTime::~MyTime()
{}; MyTime MyTime::operator+(const MyTime & time) const
{
//MyTime sum
// =MyTime(
// time.GetHour()+m_hour+(time.GetMinute()+m_minute)/60,
// (time.GetMinute()+m_minute)%60
// );
//return sum;
MyTime sum
=MyTime(
time.m_hour+m_hour+(time.m_minute+m_minute)/,
(time.m_minute+m_minute)%
);
return sum;
}; void MyTime::Show()
{
std::cout<<"Hour = "<<m_hour<<" , Minute = "<<m_minute<<std::endl;
}; //int MyTime::GetHour() const
//{
// return m_hour;
//};
//int MyTime::GetMinute() const
//{
// return m_minute;
//};
Because that's how it works in c++.In c++ access control works on
per-class basis not on per-object basis.
Access control in c++ is implemented as a static,compile-time feature.I think it is rather obvious that it is not really possible to implement any meaningful per-object access control at compile time.only per-class control can be implemented that way.
some hints of per-object control are present in protected access specification,which is why it even has its own dedicated chapter in the standard(11.5).But still any per-object features described there are rather rudimentary.Again,access control in c++ is meant to work on per-class basis.
Your "it is not really possible to implement any meaningful per-object access control at compile time". Why not? In void X::f(X&x), the compiler is easily capable of distinguishing this->a and x.a. It's not (always) possible for the compiler to know that *this and x are actually the same object if x.f(x) is invoked, but I could very well see a language designer find this OK.

In c++ access control works on per-class basis not on per-object basis.的更多相关文章

  1. protected: C++ access control works on per-class basis, not on per-object basis

    一个很简单的问题: //为什么BASE::foo()中可以直接通过p访问val? 看本记录标题,这个问题困扰了很长一段时间,终于解决class BASE {      private:        ...

  2. Oracle Applications Multiple Organizations Access Control for Custom Code

    档 ID 420787.1 White Paper Oracle Applications Multiple Organizations Access Control for Custom Code ...

  3. 开源网络准入系统(open source Network Access Control system)

    开源网络准入系统(open source Network Access Control system) http://blog.csdn.net/achejq/article/details/5108 ...

  4. [笔记] Access Control Lists (ACL) 学习笔记汇总

    一直不太明白Windows的ACL是怎么回事,还是静下心来看一手的MSDN吧. [翻译] Access Control Lists [翻译] How Access Check Works Modify ...

  5. WebGoat系列实验Access Control Flaws

    WebGoat系列实验Access Control Flaws Using an Access Control Matrix 在基于角色的访问控制策略中,每个角色都代表了一个访问权限的集合.一个用户可 ...

  6. Enhancing network controls in mandatory access control computing environments

    A Mandatory Access Control (MAC) aware firewall includes an extended rule set for MAC attributes, su ...

  7. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' heade

    XMLHttpRequest cannot load http://10.164.153.37:8050/WebService/WebService.asmx/wsGetStreetData. Res ...

  8. Windows Azure Virtual Network (10) 使用Azure Access Control List(ACL)设置客户端访问权限

    <Windows Azure Platform 系列文章目录> 本文介绍的是国内由世纪互联运维的China Azure. 我们在创建完Windows Azure Virtual Machi ...

  9. SELINUX、Security Access Control Strategy && Method And Technology Research - 安全访问控制策略及其方法技术研究

    catalog . 引言 . 访问控制策略 . 访问控制方法.实现技术 . SELINUX 0. 引言 访问控制是网络安全防范和客户端安全防御的主要策略,它的主要任务是保证资源不被非法使用.保证网络/ ...

随机推荐

  1. centos_7.1.1503_src_4

    http://vault.centos.org/7.1.1503/os/Source/SPackages/ libkcompactdisc-4.10.5-3.el7.src.rpm 05-Jul-20 ...

  2. fbx sdk

    autodesk fbx review autodesk fbx review http://www.greenxf.com/soft/169025.html autodesk fbx review( ...

  3. sicily 4699. 简单哈希

    Description 使用线性探测法(Linear Probing)可以解决哈希中的冲突问题,其基本思想是:设哈希函数为h(key) = d, 并且假定哈希的存储结构是循环数组, 则当冲突发生时,  ...

  4. [How to]如何自定义plist文件和读取plist文件内容

    1.简介 plist作为IOS的固化文件,就好比java中properties文件,但是在IOS中plist是可读写的. 本文将介绍自定义静态的plist文件. 2.自定义静态plist文件 右击你的 ...

  5. leetcode 之LRU Cache(26)

    很实际的一道题.定义一个双向链表list,方便插入和删除:定义一个哈希表,方便查找. 具体的,哈希表存放每个结点的key和它对应的结点的地址:访问结点时,如果结点存在,则将其交换到头部,同是更新哈希表 ...

  6. hive学习(一)hive架构及hive3.1.1三种方式部署安装

    1.hive简介 logo 是一个身体像蜜蜂,头是大象的家伙,相当可爱. Hive是一个数据仓库基础工具在Hadoop中用来处理结构化数据.它架构在Hadoop之上,总归为大数据,并使得查询和分析方便 ...

  7. Matlab处理数据导出Paraview可读的vtk文件(二)

    由于我在用SPH方法仿真时用的是FORTRAN语言,并且没有找到直接输出vtk文件的代码,因此偷懒通过MATLAB转换一下数据. 用到的Matlab子程序可通过一下链接找到. Matlab处理数据导出 ...

  8. AC日记——统计和 洛谷 P2068

    统计和 思路: 水题: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 100005 int n,m,tree ...

  9. Linux下文件属性

    在Linux下输入命令ls -l /etc/termcap /root/install.log,我们经常看到,这后面的一串内容具体是什么含义呢?[root@www ~]# ls -l /etc/ter ...

  10. CentOS7英文环境下使用中文输入法

    一般我们使用英文环境是没有办法使用中文的,这是因为我们没有设置在英文环境下的中文配置,下面我们在英文环境下配置中文输入法ibus使得我们可以输入中文. 首先,安装ibus(centos6以后已经默认安 ...