GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 104 of 203    Print  
Design a class for car inventory . For every new car from the manufacturer there should be minimal changes to the code.

  
Total Answers and Comments: 1 Last Update: January 10, 2008     Asked by: yathrika 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
January 10, 2008 07:16:58   #1  
wanttochange Member Since: January 2008   Contribution: 9    

RE: Design a class for car inventory . For every new car from the manufacturer there should be minimal changes to the code.
if you want to do minimal change always go for polymorphic classes..
first find the services you need ...& designa interface class that contain all methods
virtual....now we can have different cars..
so derive yr inventory class for each car from this interface


now tha benifit is this...that this design is extendible..we can add n no: of classes as child class .....may be in future we will get some other requirement....so we can add the class for that as the child class to the interface no need to changer the interface
or client code(main())

 
Is this answer useful? Yes | No

 Related Questions

Class is a user-defined data type in C++. It can be created to solve a particular kind of problem. After creation the user need not know the specifics of the working of a class.   
Latest Answer : In C, we can use only inbuilt data types for program needs but from C++ we can create userdefined datatypes in form of classes. Classes wrap datamembers and member functions that operate on datamembers together. ...

Ø      Public, protected and private are three access specifiers in C++.  Ø      Public data members and member functions are accessible 
Latest Answer : Private Protected and Public all these are access specifiers.Private Data Members are only available inside classProtected Data Members are  only available inside class as well as in derived classes.Public Data members are available ...

 Structure: Initially (in C) a structure was used to bundle different type of data types together to perform a particular functionality. But C++ extended the structure to contain functions also. 
Latest Answer : You cannot use inline functions in a structure ...

As the name suggests, the function acts as a friend to a class. As a friend of a class, it can access its private and protected members. A friend function is not a member of the class. But it must be 
Latest Answer : Friend function is used in OOP languages which allows a private or protected function to be accessed by a member outside a class. Any function outside a Class can be given access to work with members inside a class by simply writing a keyword friend ...

 A virtual function allows derived classes to replace the implementation provided by the base class. The compiler makes sure the replacement is always called whenever the object in question is actually 
Latest Answer : It is a functions whose behaviour can be overriden with an inherited class by a function of same signature. It is an important part of OOPS and Polymorphism. ...

A scope resolution operator (::), can be used to define the member functions of a class outside the class.  
Latest Answer : Scope resolution:As the name itself indicates,it resolves global scope to local scopeEx:int a=10;int main(){a=20;cout

Inheritance is the process of creating new classes, called derived classes, from existing classes or base classes. The derived class inherits all the capabilities of the base class, but can add embellishments 
Latest Answer : hi,Inheritance is the process of creating a new class called derived class from the existing class called base class. ...

 Classes and objects are separate but related concepts. Every object belongs to a class and every class contains one or more related objects.  Ø      A Class 
Latest Answer : Class is a combination of data member & member function where object is used for calling function In class we declare In object we call ...

Friend classes are used when two or more classes are designed to work together and need access to each other's implementation in ways that the rest of the world shouldn't be allowed to have. 
Latest Answer : virtual class :: It is an inner class which can be overriden by the derived classes. ...

 The idea behind inline functions is to insert the code of a called function at the point where the function is called. If done carefully, this can improve the application's performance in exchange 
Latest Answer : inline function is a function which extends the code when it is invoked. Otherwise is skip the code. ...


 Sponsored Links

 
Related Articles

Linux Thin Client Networks Design and Deployment Review

Linux Thin Client Networks Design and Deployment Review Introduction This book is written by David Richards a veteran Linux thin client network designer Designed for System Administrators Linux Thin Client Networks Design and Deployment goes over the concepts which are related to thin client network
 

jQuery Table Row Finished Code

jQuery Table Row Finished Code The Finished Code Our second example page has demonstrated table row striping highlighting tooltips collapsing expanding and filtering Taken together the JavaScript code for this page is mosgoogle geshibot lang php" document ready function var highlighted
 

jQuery Interacting with Other Code

jQuery Interacting with Other Code We learned with our sorting and paging code that we can t treat the various features we write as islands The behaviors we build can interact in sometimes surprising ways; for this reason it is worth revisiting our earlier efforts to examine how they coexist with t
 

jQuery Completed sorting and paging code

Learning jQuery The Finished Code The completed sorting and paging code in its entirety follows mosgoogle geshibot lang php" fn alternateRowColors function tbody tr odd this removeClass even addClass odd ; tbody tr even this removeClass odd addClass even ; return this; ; document
 

Concepts of Object-Oriented Programming

Object Oriented JavaScript In this chapter you ll learn about OOP Object Oriented Programming and how it relates to JavaScript As an ASP NET developer you probably have some experience working with objects and you may even be familiar with concepts such as inheritance However unless you re already a
 

Service Oriented Design and Development

Service Oriented Design and Development SOAD Service Oriented Analysis and Design The term Service Oriented Analysis and Design  was first used in the publication Elements of Service Oriented Analysis and Design Service Oriented Analysis and Design is also covered in the publication Service
 

C++ Pure Virtual Function and Base Class

C Pure Virtual Function and Virtual Base Class In this C tutorial you will learn about pure virtual function declaration of pure virtual function and virtual base class virtual base class and how to implement a virtual base class explained with examples mosgoogle center What is Pure Virtual Function
 

How to Access C++ Class Members

How to Access C Class Members In this C tutorial you will learn how to access Class members dot operator or class member access operator difference between struct and class and  scope resolution operator mosgoogle center It is possible to access the class members after a class is defined an
 

SQL Programming

SQL Programming Overview Anybody who has done something for a long time has probably wanted to change how things work at some point or another. A worker at a mill might have found a more efficient way of cutting logs, or a mathematics teacher might have had a hand in changing a school’s al
 

Systems Design

In previous chapter, we discussed system analysis and requirements stage in SDLC where everything was laid out on papers.  SDLC makes sure that there is an actual need for the software being developed.  Developers need to think of this first, especially in a business setting.&n
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape