GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 91 of 203    Print  
I want C++ code for
Create method inside Principal mentor class called assignAssociates to assign associate mentors from faculty.txt to a course. Create a file named associates.txt store CourseId,FacultyId,Role.




Overload assignAssociates function with arguments. Overloading Method1 with three arguments courseId,FacultyId,Role. Overloading Method2 with two arguments courseId,FacultyId. ( Section 6.17 from chapter 6. )
Overload methods compactly and conveniently by using function templates. Create function template for assignAssociates method

  
Total Answers and Comments: 1 Last Update: July 22, 2007     Asked by: souji1425 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 22, 2007 11:21:00   #1  
Indrajit        

RE: I want C++ code forCreate method inside Pr...

Your question is in incorrect english unclear ( how does the two assignAssociate functions differ? which parameter should we templatise?) and overall very confusing.

Which is probably why there is no previous comment on it before this one.

However to make a bleak attempt at what you are looking for:


class Principal_mentor{


public:

Principal_mentor(<pass container for course>);

~Principal_mentor(); // destructor


private public or protected( as you would want it to be):

template <class A classB...(however many template parameters you'd like)> void assignAssociate(A courseId B FacultyId C role); //Method1

template <class A class B> void assignAssociate(A courseId B FacultyId); //Method2
private:

File * faculty;

File * associates;

<declaration of container for course>;
}

Principal_mentor::Principal_mentor(<argument which is container for course>):<instantiate container for course member in the initializer list>

{

faculty fopen(faculty.txt "r"); //please check the correct syntax for the fopen

associates fopen(associates.txt "w"); // --do--


}

Principal_mentor::~Principal_mentor()

{

fclose(faculty);

fclose(associates);

}

template <class A classB...(however many template parameters you'd like)> void assignAssociate(A courseId B FacultyId C role)
{
//read one faculty name from file handle faculty
//assign it to a course.
//determine the role however you want to
//write courseId FacultyId role line into associates file handle using write or fwrite properly.
}

// construct Method2 in similar fashion.

Hope this helps you.

-Indrajit



 
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. ...

Object is a software bundle of variables and related methods. Objects have state and behavior.    
Latest Answer : An object is an instance of the class through which we can access the methods and class variables ...

Ø      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. ...

"Poly" means "many" and "morph" means "form". Polymorphism is the ability of an object (or reference) to assume (be replaced by) or become many different forms 
Latest Answer : C++ enables polymorphism - The ability of obejcts of different classes related by inheritance respond differntly to the same function call. ...

 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 ...


 Sponsored Links

 
Related Articles

BI Role in Making Corporate Decisions

BI Role in Making Corporate Decisions What is a Corporate Decision A decision that deals with the safety success and livelihood of a business can be defined as a corporate decision These decisions can range anywhere from financial issues and customer satisfaction to product popularity and environmen
 

Performing XSLT Transformations inside the Database

Performing XSLT Transformations inside the Database Now that you have the employees XSL stylesheet stored in the database and the xmlusr schema is permitted to access the hr employees table you can create a script that will instruct the database to build an HTML page based on the data stored in hr e
 

Performing XML Processing inside the Database

Performing XML Processing inside the Database When building XML enabled applications on top of Oracle there are many advantages to performing the XML processing inside the database when compared to performing it on the client The key advantages to perform XML processing inside the database are as fo
 

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&quot; 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&quot; 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
 

Developing Your Attitude Among Mentors

Developing Your Attitude Among Mentors How do I become like those I admire In the book The Master Key to Riches author Napoleon Hill interviewed over five hundred of the most successful men of his era including Henry Ford John D Rockefeller Alexander Graham Bell and Thomas Edison to get some ins
 

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
 

C++ Function Passing Types

C Function Passing Types In this C tutorial you will learn about function passing types two types of arguments passing in functions passed by value&nbsp; and&nbsp; passed by reference are discussed here mosgoogle center The arguments passed to a function can be performed in two ways Passed
 

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