C 實現全域性可讀,特定類可寫

2021-07-25 02:00:52 字數 647 閱讀 8577

關於實現以下功能的**。

1.變數i可以通過atest:getint()得到。

2.變數i只允許繼承了他的b修改。

3.維持b員工能不變。

如果哪位大神有更好的方法請告訴我 謝謝。

// test.cpp : 定義控制台應用程式的入口點。

//#include "stdafx.h"

#include "iostream"

#include "memory"

using namespace std;

class atest

protected:

void

setint(int

value)

private:

static

int i ;

};class ctest;};

class btest :public atest,public ctest

; ~btest(){};

void test()

void ssss()

};int atest::i ;

int _tmain(int argc, _tchar* argv)

return

0;}

Samba伺服器實現匿名使用者可讀可寫的實現

第一步 更改 b.conf 我們來實現乙個最簡單的功能,讓所有使用者可以讀寫乙個samba 伺服器共享的乙個資料夾 我們要改動一下 b.conf 首先您要備份一下 b.conf檔案 root localhost cd etc samba root localhost samba mv b.conf ...

C 全域性變數類

以一種更安全,更健壯的方式來表示全域性變數的方法,是將其封裝成全域性變數類,主要涉及以下的知識點 示例 全域性變數的一般寫法 string program name string version stamp int version number int tests run int tests pas...

全域性函式類內和類外實現

全域性函式類內實現 直接在類內宣告友元即可 全域性函式類外實現 需要讓編譯器提前知道全域性函式的存在 推薦使用全域性函式類內實現,編譯器可以直接識別 include include using namespace std 宣告person類 template classt1,class t2 cla...