[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

C++ practice problems for Skype Interview

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 14
Thread images: 3

File: the_door_is_over_there.png (333KB, 410x411px) Image search: [Google]
the_door_is_over_there.png
333KB, 410x411px
Hi /g/ I'm doing a skype interview soon for a tech company and I want to get more practice with C++isms / practice problems so I don't get blindsided during the interview. I have some C++ experience but its a massive language so its easy to get fucked.

Does anyone have good suggestions on things I should brush up on? I've been going through cppreference / hackerrank C++ / googling various c++ terms and writing small demos but you guys are smart and can help me thing of typical gotcha bs shit interviews throw but pertaining to C++

The list right now:

* What's the difference between static_cast, dynamic_cast, const_cast, reinterpret_cast
* What are vtables
* etc

help me avoid looking like pic related during the interview /g/ thanks.
>>
- what's auto?
- what's an rvalue reference and when would you need one?
- if you want to change a value of a member, but the method is const, how would you change the value of that member? Is it possible?
- what is a lambda function?
>>
File: damn.png (732KB, 774x835px) Image search: [Google]
damn.png
732KB, 774x835px
>>58333051
>what's auto
automatically infers the type of the variable like
auto a = 1 + 2


>whats an rvalue reference
I know what rvalues and references are but I've never used one in C++ ever will have to google

>if you want to change a value of a member but the method is const...
You can't, the entire point of the const on the method is to indicate that it doesn't modify the instance of the object.

>whats a lambda function
an anonymous function

thx for the help btw <3
>>
>>58333027
http://www.programmerinterview.com/index.php/c-cplusplus/how-vtables-work/
>>
File: g_users.png (319KB, 380x407px) Image search: [Google]
g_users.png
319KB, 380x407px
How does the friend function work ?

What are namespaces?
>>
>>58333143
no prob.

You answer to auto is correct.

Read up on rvalue references and move semantics.

Wrong. You would make the member mutable, letting the const function change that member while still being a const method. Lookup the mutable keyword.

Okay, that's what a lambda is. Can you explain why they are useful?
>>
>Be EE
>Whole point of C++ from my perspective is that you implement some obscure API.

When would one actually have to use friend and virtual functions or care about const correctnes and design objects utilizing polymorphisms etc?
>>
>>58333334
damn c++ is gross, i didn't know about mutable, thanks though

you would use a lambda in a for_each or some other construct like that to create and simultaneously use some function concisely across data, i almost never need to use them but I know why you would

>>58333392
friend is gross because giving other classes
access to your private vars seems like it would
lead to spaghetti code super quick. I'm sure
there is some use for it

const correctness is useful because it conveys to other programmers that something will NOT be modified or at least this pointer to it won't be. You want to make everything const when you can so its clear what is actually mutated.

virtual functions / polymorphism is basically vital for any kind of advanced oop design
>>
>>58333465
i use friend for unit testing private functions
>>
>>58333483
Ah useful. This is the explanation I'll give if they ask for an example usage of the friend var.

typically though wouldn't you be testing the results of the public methods on the class in the unittest and not inspecting the actual private variables themselves? I.e. we don't care what it does internally just that it produces the correct results.
>>
>>58333392
>When would one actually have to use friend and virtual functions or care about const correctnes and design objects utilizing polymorphisms etc?

Don't know about friend but virtual functions are great for a few things. Making a common interface for 2 or more similar objects. So say you want 2 objects to return something, let's say weight of animals, you can make a base class called animal and have a virtual method weight. Then child classes, let's say dog and cat, can return the weight of the dog or cat. If the object accessing the weight doesn't need to know the difference between cat and dog weight, then it can have a pointers of type animal, possibly saving hundreds of lines of code since you don't need a pointer for each specific animal.

We example, you can have a base class for electricity and child classes DC and AC. Both have a lot of the same information that can be provided, but are calculated differently. With a virtual parent, people could avoid caring what type of electricity is being accessed.
>>
>>58333465

Kind of. Yes, its nice because we can pass in lambdas to functions (std::function) -- functions are first-class constructs. Lambdas are also super nice because they *capture* local scope. Look up lambdas and capturing (by value, reference, etc).

If you want to go further, I'd recommend buying Scott Meyer's Effective C++ and then once you're done with that, reading Effective Modern C++.

Best of luck in your interview.
>>
>>58333513
Depends on your project. I could see his kind of unit testing to be useful when the interfaces haven't all been implemented yet or you have a test nazi of a boss or standard (DO-178) that requires full code testing.
>>
>>58333613
>>58333659
awesome thanks for the suggestions / info.
Thread posts: 14
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.