Expedia Interview Question for SDE-2s


Team: LSB
Country: United States
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
1
of 1 vote

Padding added to have better memory alignment for faster memory access.

class Tester {
    int foo;
    std::map<int, int> smap;
};

On 64-bit systems, pointers are 8 bytes. Compilers will align structure members to natural boundaries, so an 8-byte pointer will start at an offset in a structure that is a multiple of 8 bytes.

Since int is only four bytes, the compiler inserted 4 bytes of "padding" after foo, so that smap is on an 8-byte boundary.

- rahul thakur July 12, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A struct in C++ can have private or protected members, they are only public by default. You can use access specifiers to change that.

- Anurag June 26, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A struct is a value type so it is stored on the stack, but class is a reference type so it is stored in a heap.A structure can't support inheritance and polymorphism, but class support both. By default struct are public in nature but class are private in nature.

Padding :- In order to align the memory one or more empty bytes (addresses) are inserted between memory addresses. which are allocated for other structure member while memory allocation.This concept is called structure padding.

- Kapil July 12, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
1
of 1 vote

For C++, everything you said is wrong. Which language are you describing

- Anonymous August 04, 2014 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More