LinuxQuestions.org
Visit Jeremy's Blog.
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 04-18-2006, 12:16 PM   #1
linuxmandrake
Member
 
Registered: Sep 2004
Distribution: debian sarge 64bit (AMD)
Posts: 709

Rep: Reputation: 30
OO structure question


Is it bad structure if u access a class via another class. For example
class engine{
car.specificationclass.printme()
}

would it be better if I passed the pointer instead?
specificationclass.printme
 
Old 04-18-2006, 01:28 PM   #2
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
with that small amount of code it is really hard to tell if it is a bad design or not. i may have a (useful?) comment if you provide some more context.
 
Old 04-20-2006, 03:59 PM   #3
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
having one class inside another is a main principle in OOD, its called composition.

whether your doing it properly or not, is another question that i dont know the answer to.. as mentioned, theres very little code to analyze the situation.

are you trying to say 'an engine has a car'? at least thats what it looks like... you should have an engine object in the car class instead.
then again, i could be totally off, because im assuming this is what you want, but dont know because of the little code.

if this is an answer to your question, then good! if not, then please elaborate or give more code.. but dont overwhelm us with it.
 
  


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
directory structure question bmorency Linux - Newbie 1 10-27-2005 04:31 PM
Question, Apples Contribution to Open Source + MacOs file structure question Higgy3k Other *NIX 5 07-25-2005 04:23 AM
File system/structure question ashley75 Linux - General 1 05-17-2005 09:02 PM
c++ structure-array question deveraux83 Programming 2 01-01-2004 08:55 AM
structure question Lostman Linux - Newbie 1 11-04-2003 02:01 AM

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

All times are GMT -5. The time now is 07:45 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