LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-05-2009, 09:12 AM   #1
naveenisback
Member
 
Registered: Jun 2009
Posts: 80
Blog Entries: 1

Rep: Reputation: 16
help to design class diagram


Hi to all


I want to know how to relate classes in c++.

For Ex:

My project is to get the system information like monitor, cpu, os , network..

So how can i design a class diagram.. which 1 is good among following

1.take computer as base class , and monitor , cpu, os as derived class.

2. Take computer as base class and treat Monitor cpu, OS as agregates of Computer..


And one more question

How can i implement if i consider any one among above.


How to upload a diagram to this forum..
sori for bad english

Last edited by naveenisback; 10-05-2009 at 09:14 AM.
 
Old 10-05-2009, 09:43 AM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
One of the best (if not only) ways to get help with homework - not that I have anything against helping people with their homework - is to show us some of the work you have already done.

As far as uploading a diagram, I suggest uploading the file to some personal web space (if you have some, that is) and just posting a link.

 
Old 10-05-2009, 10:04 AM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by naveenisback View Post
My project is to get the system information like monitor, cpu, os , network..
Your other threads don't sound like homework. So I don't know how to react to this one that does.

Quote:
1.take computer as base class , and monitor , cpu, os as derived class.
When you try to model physical reality with object oriented inheritance you are looking for "is a kind of" relationships. So "computer" as base class for "monitor" would make sense if "a monitor is a kind of computer". You can't intend that, and I can't think of anything else you might intend with computer as the base class for monitor.

Did you mean computer_part as the base class?

Quote:
2. Take computer as base class and treat Monitor cpu, OS as agregates of Computer..
It's even harder to figure out how that is supposed to make sense.

A computer might be an aggregate of computer_parts.

I haven't looked at the source code for the open source project lshw. But it seems to be available easily. A web page on that subject says it is C++ code. It takes a very structured approach to reporting the characteristics of computer components. So it might be a good example to look at. There is a clear advantage to looking at the work of someone who did a good job at a similar task, rather than asking the random opinions of those who might reply to a thread like this.

Last edited by johnsfine; 10-05-2009 at 10:09 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux for Graphic Design, web design, and publishing maelstrom209 Linux - Software 8 07-17-2011 11:35 AM
Java - one class for all? Java Design. trscookie Programming 4 02-07-2008 06:06 PM
C++ templated Node class: pointers to different instantated class types jhwilliams Programming 3 08-20-2007 06:20 PM
Does derivated class inherit base class destructor (constructor)? kornerr Programming 2 08-23-2006 08:05 AM
Which C++ editor in Linux has the class view/class browser feature imaginationworks Programming 7 05-21-2006 11:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration