Walmart Interview Question: Whatt is the Suggestions for ... | Glassdoor

Interview Question

Computer Operator Interview Pittsburgh, PA

Whatt is the Suggestions for C Programmers ?


Interview Answer

2 Answers


[1] Macros are almost never necessary in C++. Use c o n s t (§5.4) or e n u m (§4.8) to define manifest
constants, i n l i n e (§7.1.1) to avoid functioncalling
overhead, t e m p l a t e s (Chapter 13) to
specify families of functions and types, and n a m e s p a c e s (§8.2) to avoid name clashes.
[2] Don’t declare a variable before you need it so that you can initialize it immediately. A
declaration can occur anywhere a statement can (§6.3.1), in forstatement
(§6.3.3), and in conditions (§
[3] Don’t use m a l l o c (). The n e w operator (§6.2.6) does the same job better, and instead of
r e a l l o c (), try a v e c t o r (§3.8).
[4] Try to avoid v o i d *, pointer arithmetic, unions, and casts, except deep within the implementation
of some function or class. In most cases, a cast is an indication of a design error. If
you must use an explicit type conversion, try using one of the ‘‘new casts’’ (§6.2.7) for a
more precise statement of what you are trying to do.
[5] Minimize the use of arrays and Cstyle
strings. The C++ standard library s t r i n g (§3.5) and
v e c t o r (§3.7.1) classes can often be used to simplify programming compared to traditional C
style. In general, try not to build yourself what has already been provided by the standard

Interview Candidate on Jun 17, 2012

If you're looking for interview questions, try Rooftop Slushie - it's the easiest way to get questions and answers from current employees at Google, Facebook, Amazon, and +50,000 companies.

Anonymous on Jul 9, 2019

Add Answers or Comments

To comment on this, Sign In or Sign Up.