#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. openboot的项目

    http://docs.oracle.com/cd/E19201-01/821-0901-10/OK_OBP.html https://www.openfirmware.info/OpenBIOS h ...

  2. BZOJ 2002: [Hnoi2010]Bounce 弹飞绵羊 动态树

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2002 题意:加边,删边,查询到根的距离. #include <bits/stdc++ ...

  3. PHP常用函数总结(180多个)

    PHP常用函数总结 数学函数 1.abs(): 求绝对值 $abs = abs(-4.2); //4.2 数字绝对值数字 2.ceil(): 进一法取整 echo ceil(9.999); // 10 ...

  4. Python 什么是ORM?

    关系映射 性能比源生sql效率略差一些 操作性更简单,快捷 Django的orm和sqlalchamy 区别 sqlalchamy没有django的功能全,不支持双下划线的连表跨表操作 sqlalch ...

  5. 数据库之各种键(Key)

    超键(super key):在关系中能唯一标识元组的属性集称为关系模式的超键候选键(candidate key):不含有多余属性的超键称为候选键主键(primary key):用户选作元组标识的一个候 ...

  6. stl 学习笔记

    1. Erasing multiple objects from a std::vector https://stackoverflow.com/questions/3487717/erasing-m ...

  7. WP评论系统更换小结(转)

    第三方评论插件 多说 多说是一款追求极致体验的社会化评论框,可以用微博.QQ.人人.豆瓣等帐号登录并评论. 多说具备优质用户体验.速度和稳定性.社会化推荐.建站程序审核整合.垃圾评论过滤等特性. 自定 ...

  8. 前端读者 | 如何判断Javascript对象是否存在

    本文来自@阮一峰 Javascript语言的设计不够严谨,很多地方一不小心就会出错. 举例来说,请考虑以下情况. 现在,我们要判断一个全局对象myObj是否存在,如果不存在,就对它进行声明.用自然语言 ...

  9. 关于自建yum源拾遗

    yum参数解释[updates]--->源name=CentOS-$releasever - Updates --->源的名字baseurl=http://mirror.centos.or ...

  10. POJ 1845 Sumdiv (整数唯一分解定理)

    题目链接 Sumdiv Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 25841   Accepted: 6382 Desc ...