You are on page 1of 3

C++ notes for discussion | TechInterviews http://www.techinterviews.

com/c-notes-for-discussion

Search Tech Interviews

Tech Interviews
Prepare for job interviews with the questions and answers asked by high-tech employers

.NET C++ Database General Hardware Java Networking Puzzles SAP ABAP Testing Unix/Linux VB Web dev Windows

C++ >> C++ notes for discussion

1 of 3 27-03-2010 9:32 AM
C++ notes for discussion | TechInterviews http://www.techinterviews.com/c-notes-for-discussion

C++ notes for discussion


By admin | February 6, 2006

This is not really a set of interview questions, a reader sent TechInterviews.com what looks like a copy
of his notes from C++ class that describes various tricks and code for C++.

1. What is the output of printf(“%dâ€Â)?


A. %d helps to read integer data type of a given variable
B. when we write (“%dâ€Â, X) compiler will print the value of x assumed in the
main
C. but nothing after (“%dâ€Â) so the output will be garbage
D. printf is an overload function doesnt check consistency of the arg list –
segmentation fault
2. What will happen if I say delete this? - destructor executed, but memory will not be freed
(other than work done by destructor). If we have class Test and method Destroy { delete this }
Job Interview Question Articles
the destructor for Test will execute, if we have Test *var = new Test()
C# Interview Questions and Answers
A. pointer var will still be valid
QTP Interview Questions and Answers
B. object created by new exists until explicitly destroyed by delete
C++ Interview Questions and Answers
C. space it occupied can be reused by new
PHP Interview Questions and Answers
D. delete may only be applied to a pointer by new or zero, applying delete to zero = no FX
XML Interview Questions and Answers
E. delete = delete objects
JavaScript Interview Questions and Answers
F. delete[] – delete array
Asp.Net Interview Questions and Answers
G. delete operator destroys the object created with new by deallocating the memory assoc.
J2EE Interview Questions and Answers
with the object
ABAP Interview Questions and Answers
H. if a destructor has been defined fir a class delete invokes that desructor
Perl Interview Questions and Answers
Java Interview Questions and Answers
3. Difference between C structure and C++ structure - C++ places greater emphasis on
type checking, compiler can diagnose every diff between C and C++
A. structures are a way of storing many different values in variables of potentially diff types
Resources
under under the same name
Technology Question and Answer Website
B. classes and structures make program modular, easier to modify make things compact
How to dance around the salary-expectation question
C. useful when a lot of data needs to be grouped together
10 mistakes managers make during job interviews
D. struct Tag {…}struct example {Int x;}example ex; ex.x = 33; //accessing variable
ID Maker
of structure
Stupid interview questions
E. members of a struct in C are by default public, in C++ private
How to Answer These Tricky Interview Questions
F. unions like structs except they share memory – allocates largest data type in
Seven tips for writing an online profile for LinkedIn,
memory - like a giant storage: store one small OR one large but never both @ the same
MySpace or Facebook
time
Video surveillance
G. pointers can point to struct:
Ink cartridges
H. C++ can use class instead of struct (almost the same thing) - difference: C++ classes can
Laptop computers
include functions as members
Affordable life insurance
I. members can be declared as: private: members of a class are accessible only from other
Ink cartridges
members of their same class; protected: members are accessible from members of their
same class and friend classes and also members of their derived classes; public:
members are accessible from anywhere the class is visible
Tutorials
J. structs usually used for data only structures, classes for classes that have procedures and
AJAX Tutorials
member functions
Dealing with your job
K. use private because in large projects important that values not be modified in an
Getting a job
unexpected way from the POV of the object
JavaScript tutorials
L. advantage of class declare several diff objects from it, each object of Rect has its own
Job interview tips from Yahoo! HotJobs
variable x, y AND its own functions
MySQL tutorials
M. concept of OO programming: data and functions are properties of the object instead of
Retiring from your job
the usual view of objects as function parameters in structured programming
Ruby on Rails tutorials
4. Difference between assignment operator and copy constructor - -assignment
Salary guide for IT jobs
operator = assigning a variable to a value - copy constructor
Self-employment
A. constructor with only one parameter of its same type that assigns to every nonstatic class
TechInterviews guides in PDF
member variable of the object a copy of the passed object
Understanding pointers
B. copy assignment operator must correctly deal with a well constructed object - but copy
XML Tutorials
constructor initializes uninitialized memory
XUL tutorials
C. copy constructor takes care of initialization by an object of the same type x
D. for a class for which the copy assignment and copy constructor not explicitly declared
missing operation will be generated by the compiler. Copy operations are not inherited -
RSS Feeds
copy of a class object is a copy of each member
All posts
E. memberwise assignment: each member of the right hand object is assigned to the
All comments
corresponding member of the left hand object
F. if a class needs a copy constructor it will also need an assignment operator
G. copy constructor creates a new object, assignment operator has to deal w/ existing data
in the object
H. assignment is like deconstruction followed by construction
I. assignment operator assigns a value to a already existing object
J. copy constructor creates a new object by copying an existing one
K. copy constructor initializes a freshly created object using data from an existing one. It
must allocate memory if necessary then copy the data
L. the assignment operator makes an already existing object into a copy of an existing one.
M. copy constructor always creates a new object, assignment never does

2 of 3 27-03-2010 9:32 AM
C++ notes for discussion | TechInterviews http://www.techinterviews.com/c-notes-for-discussion

Powered by WordPress. Built on the Thematic Theme Framework.

3 of 3 27-03-2010 9:32 AM

You might also like