Click here to Skip to main content
15,903,385 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
GeneralRe: How to design the accessibility problem Pin
SSETH7-Feb-16 7:29
SSETH7-Feb-16 7:29 
C++
class AccountInterface
{
public :
	virtual void CheckAccount() = 0;
};


class Accountant 
{
private:
	AccountInterface * accountDept;
public:
	Accountant():accountDept(NULL){}
	void SetCompanyAccDept(AccountInterface *accDept){accountDept = accDept;}

	void AuditCompany()
	{
		if (accountDept)
			accountDept->CheckAccount();
		else
			printf("Compnay info not set");
	}
};

class company : private AccountInterface
{
private:
	virtual void CheckAccount()
	{
		printf("Only Granted Accountant should have access to this");
	}
public:
	void SetAccuntant(Accountant *accountant)
	{
		//Based on some logic grant access
		accountant->SetCompanyAccDept(this);
	}
};

int main (int argc, char *argv[])
{
	company c1;
	Accountant ac1;
	c1.SetAccuntant(&ac1);
	ac1.AuditCompany();
	
}


I tried to demonstrate the idea with a company its account deptartment and an accountant.

Account Details should not be public. (no Public access)
The Accountant should not be able to access other details of the company ( No friend)
Company is responsible for granting access permission --Private Inheritance..( is a relationship with base class but no exposed to public)

Thanks,
SSETH
GeneralRe: How to design the accessibility problem Pin
Richard MacCutchan7-Feb-16 21:05
mveRichard MacCutchan7-Feb-16 21:05 
GeneralRe: How to design the accessibility problem Pin
SSETH7-Feb-16 22:00
SSETH7-Feb-16 22:00 
GeneralRe: How to design the accessibility problem Pin
Richard MacCutchan8-Feb-16 3:03
mveRichard MacCutchan8-Feb-16 3:03 
GeneralRe: How to design the accessibility problem Pin
jschell12-Feb-16 12:31
jschell12-Feb-16 12:31 
QuestionOpinions on dividing up a single entity framework layer in source control Pin
darkliahos4-Feb-16 5:18
darkliahos4-Feb-16 5:18 
AnswerRe: Opinions on dividing up a single entity framework layer in source control Pin
Gerry Schmitz4-Feb-16 7:25
mveGerry Schmitz4-Feb-16 7:25 
GeneralRe: Opinions on dividing up a single entity framework layer in source control Pin
darkliahos6-Feb-16 2:38
darkliahos6-Feb-16 2:38 
GeneralRe: Opinions on dividing up a single entity framework layer in source control Pin
Gerry Schmitz6-Feb-16 5:44
mveGerry Schmitz6-Feb-16 5:44 
AnswerRe: Opinions on dividing up a single entity framework layer in source control Pin
jschell6-Feb-16 13:29
jschell6-Feb-16 13:29 
QuestionFile Sharing App (DropBox) Propose Architecture Pin
zephaneas3-Feb-16 9:30
zephaneas3-Feb-16 9:30 
AnswerRe: File Sharing App (DropBox) Propose Architecture Pin
Gerry Schmitz4-Feb-16 7:48
mveGerry Schmitz4-Feb-16 7:48 
GeneralRe: File Sharing App (DropBox) Propose Architecture Pin
Kevin Marois4-Feb-16 8:41
professionalKevin Marois4-Feb-16 8:41 
GeneralRe: File Sharing App (DropBox) Propose Architecture Pin
Gerry Schmitz4-Feb-16 9:18
mveGerry Schmitz4-Feb-16 9:18 
GeneralRe: File Sharing App (DropBox) Propose Architecture Pin
Kevin Marois4-Feb-16 9:30
professionalKevin Marois4-Feb-16 9:30 
GeneralRe: File Sharing App (DropBox) Propose Architecture Pin
Gerry Schmitz4-Feb-16 9:36
mveGerry Schmitz4-Feb-16 9:36 
GeneralRe: File Sharing App (DropBox) Propose Architecture Pin
Kevin Marois4-Feb-16 9:41
professionalKevin Marois4-Feb-16 9:41 
QuestionDropBox Type Of App Pin
zephaneas2-Feb-16 10:30
zephaneas2-Feb-16 10:30 
AnswerRe: DropBox Type Of App Pin
Eddy Vluggen2-Feb-16 12:41
professionalEddy Vluggen2-Feb-16 12:41 
GeneralRe: DropBox Type Of App Pin
Kevin Marois3-Feb-16 7:57
professionalKevin Marois3-Feb-16 7:57 
GeneralRe: DropBox Type Of App Pin
Eddy Vluggen3-Feb-16 8:40
professionalEddy Vluggen3-Feb-16 8:40 
AnswerRe: DropBox Type Of App Pin
jschell2-Feb-16 13:30
jschell2-Feb-16 13:30 
GeneralRe: DropBox Type Of App Pin
Kevin Marois3-Feb-16 7:58
professionalKevin Marois3-Feb-16 7:58 
GeneralRe: DropBox Type Of App Pin
Eddy Vluggen3-Feb-16 8:48
professionalEddy Vluggen3-Feb-16 8:48 
GeneralRe: DropBox Type Of App Pin
zephaneas3-Feb-16 8:52
zephaneas3-Feb-16 8:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.