#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. canvas制作柱形图/折线图/饼状图,Konva写动态饼状图

    制作饼状图 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  2. strtok的用法(文件操作)

    strtok :在一个字符串查找下一个符号 char *strtok( char *strToken, const char *strDelimit ); 返回值:返回指向在strToken字符串找到 ...

  3. HDU-4255

    A Famous Grid Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  4. POJ-2563

    Pick-up sticks Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 10364   Accepted: 3842 D ...

  5. react与mox-react的shouldComponentUpdate 理解

    react性能优化中,提到的就是通过 React.PureComponent 替换 React.Component 组件进行编程. 两个组件之间的不同主要就是PureComponent做了should ...

  6. AC日记——Sagheer and Nubian Market codeforces 812c

    C - Sagheer and Nubian Market 思路: 二分: 代码: #include <bits/stdc++.h> using namespace std; #defin ...

  7. 如何实现electron多页面间通信

    如何实现electron多页面间通信 1,业务需求: 总共有两个页面,页面A显示数据,页面B处理数据,主线程Main 2,实现的技术方案: 在主线程中打开页面A和B,B页面不进行显示,主要负责处理从A ...

  8. CentOS7配置redis主从复制

    规划 ip port role 192.168.1.31 6379 master 192.168.1.32 6379 slave 192.168.1.33 6379 slave 0.关闭防火墙 sys ...

  9. 将excel中的sheet1导入到sqlserver中

    原文地址:C#将Excel数据表导入SQL数据库的两种方法作者:windream 方式一: 实现在c#中可高效的将excel数据导入到sqlserver数据库中,很多人通过循环来拼接sql,这样做不但 ...

  10. JDBC浅析

    今天简单的说一下jdbc,本来这玩意儿也很简单. 大家只需要记住其中的几个重要的类就行了,它们都在sql包里.今天主要是拿mysql来连接.先看一下主要的几个类吧. 1.Conenction 2.St ...