#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. oracle to_char 返回毫秒级

    select to_char(systimestamp,'yyyy-mm-dd hh24:mi:ssxff') time1, 关键在 systimestamp

  2. P1968

    题目背景 此处省略maxint+1个数 题目描述 在以后的若干天里戴维将学习美元与德国马克的汇率.编写程序帮助戴维何时应买或卖马克或美元,使他从100美元开始,最后能获得最高可能的价值. 输入输出格式 ...

  3. linux命令(37):locate命令

    1.命令格式: Locate [选择参数] [样式] 2.命令功能: locate命令可以在搜寻数据库时快速找到档案,数据库由updatedb程序来更新,updatedb是由cron daemon周期 ...

  4. 百度之星资格赛--IP聚合

    IP聚合 Accepts: 1901 Submissions: 4979 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/6553 ...

  5. Django web框架之权限管理二

    1. login登录 def login(request): if request.method=="GET": return render(request,'login.html ...

  6. hdu 1495(BFS)

    非常可乐 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  7. poj 1692(动态规划)

    Crossed Matchings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2711   Accepted: 1759 ...

  8. [你必须知道的.NET]第二十五回:认识元数据和IL(中)

    发布日期:2009.02.25 作者:Anytao © 2009 Anytao.com ,Anytao原创作品,转贴请注明作者和出处. 说在,开篇之前 书接上回[第二十四回:认识元数据和IL(上)], ...

  9. 操作cephfs的基本命令

    [前提是已有一个基本可用的ceph集群] 一,在指定节点上部署mds: ceph-deploy mds create ceph-node1 二,新建两个存储池,用于保存cephfs的数据和元数据. c ...

  10. Bootstrap新版里的a标签点击后出现下划线解决办法

    其实我从失去焦点后发现了下划线消失了就应该知道 Bootstrap对a标签进行了 focus焦点事件. 所以解决办法就是一句:a:focus{text-decoration: none}. 一个笑笑的 ...