Saturday, May 9, 2009

C++ STL question?

I had a programming interview yesterday, and I really blew the C++ Q/A part because I couldn't remember how iterators are used with containers. The guy asked: "Why are iterators separate classes rather than member functions?" I thought he was trying to trick me so i said: "No, they're member functions, of that particular container class."





Who was right? Ten points for the most lucid and detailed answer.

C++ STL question?
Sorry to say he is right. The iterator class is actually from std::iterator. The reason they are their own class is that you can inherit from this base class to make your own iterator for your own container. Not every container has every type of iterator either.





A user may need to specify their own iterator for their own container and implement its functionality for "iterator safety". Maybe the iterator jumps in a specific sequence, maybe it moves to every other item in the collection. Maybe it needs to pull out or expose certain information from the container. Who knows. I have never really seen it being done because most people are looking for sequential iteration either forward, backward or bidirectional.





Some will even say inheriting from the base iterator might be a bad idea and that you could actually create a class that just uses a standard iterator and you add the extra functionality in the class. But it is all opinion.





Oh and one other thing, not all iterators are associated with a container.... take the istream and ostream iterators for example.





But it is clearly its own class defined in the STL.





Good luck with future interviews!

gladiolus

What are C# analogues of the C++ STL?

I suppose C# has default classes for basic data structures in a way similar to that of the STL for C++. What are they and where can I get information about them?

What are C# analogues of the C++ STL?
C# is more closely related to Java than C++. Each of the standard classes can be found by some using declaration on the System set of classes.





For instance System.Collections.Generic would give you access to Stacks, Lists, and Arrays.
Reply:Yeah, the System.Collections and System.Collections.Generics namespaces are what you are looking for. Generics are more powerful than template classes, you can put constraints on the type parameters and they have better compile time error checking.


In c++ STL Difference betwen pair<const char,int> and map<char,int>?

in c++ STL Difference betwen pair%26lt;const char,int%26gt; and map%26lt;char,int%26gt;?


pleas explain operation of each function.

In c++ STL Difference betwen pair%26lt;const char,int%26gt; and map%26lt;char,int%26gt;?
Google works best.





(Hint: pair is utility element. It's a single unit. Map is a giant list of such pair units, where a pair is a key and its data.)
Reply:map can be considered as list of pairs


C++ STL Interview questions?

I have a C++ programing interview next week. I am a recent graduate and have worked in C++ for a year and have used STL a few times, but have never used it extensively. I just wanted to know, How should I prepare for STL related questions ? What should I focus on to brush up STL ?

C++ STL Interview questions?
You can search at job interview question and answer website like http://jobinterviewquestion.org/ .
Reply:A tough interview question is any question that you're not prepared for. Below are some sample questions you might be asked during a job interview. For each question, formulate a thoughtful answer. Then memorize it. Being prepared to answer these (or similar) questions will make you more comfortable and confident in any job interview – and increase your chance of being hired.





Never work alone--pay attentions on the social-network.


The social-network is fatal factor for your work present and future, the social-network is the your connections in the society, it can be your parent,friend,classmate,colleagues etc.Good scoial-network can improve your efficiecy, not only on the work itself but also good for your entire future career path.(job-hunting, recruit, professional personal development,life and work advice etc.http://rds.yahoo.com/_ylt=A0oGkmPLtLlH0m...


The Free Insiders Referral Network of Jobs %26lt;/a%26gt; is such tool for your to build such useful network.To expand and enhence your social-network and make it more useful, just go and check it up.





Knowledge of Yourself


In five words or less, describe yourself. Tell me about yourself. Describe your best friend. Tell me a story. What are your weaknesses? (or: What areas of your job performance could be improved? or: What would you find most challenging about this job?) What special skills do you have? What have you accomplished? What are your goals? Why should I hire you?


Knowledge of the Employer


Why do you want to work for us? How could you contribute to our company's goals? Evaluate your most recent employer. What do you expect from an employer? What is the greatest challenge facing our field today? What sets us apart from our competitors?


Work Environment


Tell me about a problem you once had on the job, and how you solved it. How does an ideal manager make you successful? In your opinion, is conflict inevitable? What is more important to you – Speed or Neatness? Have you ever been injured at work or at home? How many days were you absent from work last year? How many times were you late for work? Have you ever quit or been fired from a job? Why did you leave your last job? What is more important to you – Wages or Job Satisfaction? What are your salary expectations? Would you consider working without pay, and if so, under what circumstances? How do you feel about working overtime?


Personality Traits


How do you handle disagreements with your superiors? Do you feel comfortable delegating tasks? What tasks do you like the least? What types of people do you work best with? Are there any types of people who "rub you the wrong way?" Are you a leader or a follower? In your last job, what was your biggest disappointment? What motivates you? What makes you angry? What's the greatest honour you’ve ever had? How well do you handle criticism?


Negativity


You seem overqualified for this position; wouldn't you become bored and want to quit? We're looking for a younger person. We can't match the salary you were earning at your previous job.


If you're not sure how to answer one or more of these questions, contact the Ausable Employment Resource Centre and ask for assistance.








Preparing for a Job Interview


You've researched the company that wants to interview you, answered the 40 sample questions that appeared in the previous article, washed the clothes you'll be wearing, and polished your shoes. Are you ready for the interview? Not yet! Here's what else you should do in preparation:


Appraise Yourself. Review your accomplishments by thinking of specific examples. Write them on paper and say them out loud. If you've babysat a total of 16 children aged six months to six years over the past four summers, say so. If you haven't missed a day of work (or school) in two years, say so. If you've catered seven banquets of up to 100 people, say so. If you won an award for the best safety record in your company, say so. These are noteworthy accomplishments; give yourself credit where credit is due.





Think Benefit. Job interviewers want to know how you can benefit their business more than all other competing applicants, so make sure you tell them. Why isn't a list of job duties and responsibilities good enough? Because:





It doesn't show proficiency or skill level.


It doesn't show initiative, creativity, or problem-solving ability.


It doesn't distinguish you from other workers doing the same job.


It doesn't show how an employer benefitted from having you as an employee.


If you were an employer, would you rather hire someone who says "I did month-end mailings." or someone who says "By computerizing our month-end mailings, I reduced an 8-hour job to 1 hour." Would you rather hire the applicant who says "I transported pallets to a sanitary landfill." or the applicant who says "They had always taken their pallets to the dump. I used the pallets to make compost bins, and sold them for $20 each."


Give employers enough good reasons to hire you, and they probably will.


Prepare Questions. Make a list of questions to ask the interviewer. Topics might include the company, the industry, products and services, work environment, job details, who you report to, when you'll be contacted, etc. Whichever questions aren't answered during the course of the interview can be asked at the end.





Contact Your References. Tell them the date of your interview, the company's name, and the position you're applying for. Make sure they have a copy of your resume. Remind them of your goals and why you would be a great candidate for this job. Ask if they have any questions, and thank them for their help.





Plan Ahead. Don't be late for the interview! If you're not sure of the location, phone and ask for directions. The day before the interview, go to the location and note how long it takes to get there. Are there train crossings, detours, or road construction along the route? Don't worry if you take a wrong turn and get lost, or you end up at 450 Park Ave North instead of South: the interview is tomorrow, and you won't make the same mistake again.





If you're not doing all of these things in advance, you're not as prepared as you could be.





The Job Interview


When job interviewers meet you in person, they want to find out three important things, namely: 'Why are you here?' 'How can you help us?' and 'What kind of person are you?' (these questions are rarely asked directly, but they could be, so be prepared to answer).


Why are you here? This is another way of asking "Why do you want to work here specifically?" If you've answered this in your cover letter, great! Now repeat out loud how the company's goals, philosophy, mission, business practices, service policies, innovations, etc. coincide with your own objectives, values, and background. If you haven't researched the company, too bad for you; your lack of interest in the employer will be mirrored by the employer's lack of interest in you.





How can you help us? This question asks how your knowledge, skills, and accomplishments will benefit the employer. Again, if you've stated this in your resume and cover letter, excellent! Now say it again and back it up with concrete evidence that you've brought to the interview.





This "evidence" doesn't have to be a full portfolio – just a few well-chosen samples that provide proof of your KSAs. Some examples: academic transcripts, letters of recommendation, employee evaluations, awards, newspaper or magazine articles, brochures, technical drawings, creative designs, paintings, photographs, illustrations, diagrams, sketches, charts or graphs, product samples, scale models, inventions or innovations, displays, presentations, reports, essays, research papers, experimental results/conclusions/summaries, project outlines or synopses, contract proposals, business plans, cost/benefit analyses, program developments. If an opportunity to "show your stuff" doesn't arise during the interview, ask to present it at the end, and then offer to leave your samples for the interviewers to further examine at their leisure.





What kind of person are you? Call it what you want (personality, behaviour, attitude, character, temperament, disposition, etc.), the kind of person you are is extremely important, and is often the determining factor in whether you get hired. Moreover, it's something that interviewers evaluate merely by watching and listening, so there's no point in you trying to convince them with words – their observations will be the judge. If they want second opinions on your personality, they'll ask other interviewers or contact your references and ask for a candid assessment.





Nevertheless, the following tips can help to make a good impression: Dress appropriately for the position you're applying, be courteous to everyone you meet, remain alert and attentive, and thank the interviewer(s) before you leave. If you don't understand a question, ask the person to rephrase it. If you're having trouble formulating a reply within a reasonable time, ask to come back to that question later. When asked a Yes or No question, elaborate. And when you can't answer a factual question, an "I don’t know" response is better than wading blindly into a pool of quicksand.





After the Interview


Take Notes


Immediately after a job interview, find a place to sit down and write some notes for yourself. Record the following information before you forget: