[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]

Things that your C++ teacher keeps doing

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: 47
Thread images: 2

File: smug 1.jpg (136KB, 560x570px) Image search: [Google]
smug 1.jpg
136KB, 560x570px
I'll start:
Keeps using #include<conio.h>
>>
i had to look that up
>conio.h is a C header file used mostly by MS-DOS compilers to provide console input/output. It is not part of the C standard library or ISO C, nor is it defined by POSIX.

why the fuck would anyone use that?
>>
He does it to work with console input and output in an MS-DOS fashion, I'm assuming. Get a little understanding of how that compiler does things.
>>
>>58286951
idk but it seems to be used a lot, specially in early grade courses.
>>
He's probably just old school. When I was in college doing c++ in the late 90s, lower level classes used Windows labs with Borland c++. Thankfully 300 and up used the Linux labs.
>>
You have to be 18 or older to use this site, kiddo.
>>
>>58286940
I had a more esoteric instructor for a C course back in 2008 that used the same library.

We later did some C++ stuff and were instructed to use Embarcadero RAD.

Everybody has their own quirks, I guess.
>>
>>58286940
using namespace std;
>>
conio.h is required in Turbo C compiler.
Is your teacher Indian?
>>
>>58287847
C++ Builder is bretty based desu.
>>
Mine used new for allocation and free for deallocation.

He also didn't know what undefined behavior was, and kept creating it by mixing pre and post increment during assignment.

Poor soul.
>>
File: rwVGW.gif (649KB, 480x228px) Image search: [Google]
rwVGW.gif
649KB, 480x228px
>half of code is 2 letter macro functions
>he "used" C++
>>
>>58288456
what is wrong with this?
>>
Iugh, conio is shit.

"Buah, I can't use cout and cin".

Fags.
>>
>>58290551
In 99.99999999% of cases, nothing
Especially true in 2016
>>
>>58290590
>2016
>>
>>58290551
Depends on where you put it.

In a source file, there's nothing wrong with it.

If you put it in a header file you include other places, however, it may be a massive issue.

You have to remember that std is massive, there is a fuckton of classes and functions. If you by accident name one of your own functions or classes the same thing, you might end up in a scenario where you think you're using your own implementation but are using the std version.

Namespaces are there for a reason. If there is some common type that you use frequently and you get tired of writing
std::shared_ptr<MyClass> myClassPointer;
all the time, you should consider using a typedef instead
typedef::shared_ptr<MyClass> MyClassPtr;
>>
>>58290662
why typedef and not
using std::shared_ptr
>>
>>58286940
conio sounds like "cunt" in spanish
>>
>>58290738
Well, that's obviously fine too, but then you'd have to type

shared_ptr<MyClass>


everywhere
>>
>>58286976
This. OP's just one of the many undergrads with superiority complex.
>>
>>58291081
Which is good.
I hate crawling some faggots codebase and look up/jump to redefinitions that often have adventurous names.
>>
I envy your class. My teacher only taught me some useless MS-DOS shit. When it was already obsolete
>>
>>58291181
>Which is good.
No it's not, because what if you want to make MyClass uncopyable, then you need to change all the references instead of simply changing the MyClassPtr type declaration.
>>
>>58291181
Fucking this, I'm tired of retards typedefing simple maps to shitty names. Combine that with hungarian notation and I'm raging.
>>
>>58291304
>What is search and replace

Literally a non-issue.
Readability is king, idiotic typedefs are all but readable.
>>
>>58286940
>>58286951

At least when I had basic prog, we were using a non-standardized C from the early 90s. This was in 2011, but for some reason they taught us with that instead of an ANSI.
>>
>>58291304
>because what if you want to make MyClass uncopyable
not my fault if you are following standard C++ faggotry of creating copy constructors for everything, if that is what you're on about
same with const-ing everything
no pitty there

No reason to follow such cancer idioms.
>>
>>58291331
>>58291312
What is more readable?

>SomeLongClassNamePtrMap
or
std::map<mynamespace::SomeLongClassName::IdentifierType, std::shared_ptr<mynamespace::SomeLongClassName> /* don't remove this space or you're fucked */ >
>>
>>58291375
The lower one, because I know what it is and don't need to look up what the retarded faggot meant when he wrote the typedef.
>>
>>58291375
Obviously there is a threshold when it comes to readability and this clearly crosses it. Most maps do not however.

Also,
>/* don't remove this space or you're fucked */
use C++11 already.
>>
>>58291404
I guess you're the kind of guy that doesn't like explanatory variable names either, because you don't believe in that, am I right?
>>
>>58291426
>I guess you're the kind of guy that doesn't like explanatory variable names either, because you don't believe in that, am I right?
I don't like explanatory variables if they are less explanatory than the author thought they would be. Which is surprisingly often.
>>
instead of writing constructor or destructor he write ctor/dtor
>>
>>58291426
What? Variables need a name, but container specialization doesn't need typedef. Being overly verbose is bad.
>>
>>58291373
If you're refusing C++ idioms, why even bother using C++? STL containers and RAII and exceptions?
>>
>>58291483
>What? Variables need a name, but container specialization doesn't need typedef
No, but see >>58291375

>Being overly verbose is bad.
Are you trolling? I'm literally arguing that typing out the specification is overly verbose when a typedef will do.
>>
>>58291375
typedef mynamespace::SomeLongClassName::IdentifierType MyShittyType;
typedef std::shared_ptr<mynamespace::SomeLongClassName MyShittyClassPtr
std::map<MyShittyType, MyShittyClassPtr>

Is the best of both worlds desu, if you're using a map of those types it's assumed you'll be using those types later in your code too, only a retard stackoverflow poster would turn the map into a typedef instead of the actual types
>>
>>58291510
Verbose in terms of having to follow unnecessary indirections. Shitty entreprise code already have enough of those not to need any more.
>>
>>58291527
>Is the best of both worlds desu,
It depends on how frequently you pass a map type around

>if you're using a map of those types it's assumed you'll be using those types later in your code too
C++11 and newer has type inference, so no, that's not given.

Sometimes only a collection of something makes sense.

>only a retard stackoverflow poster would turn the map into a typedef instead of the actual types
That map specification is regarded as a specific type too


>>58291554
I'm arguing that types should have sensible names, the same way variable names should be. If you're able to infer the type from the name, why bother explicitly typing the name?
>>
>>58291636
>It depends on how frequently you pass a map type around
I'd wager money that the map type would get used a lot less than the other ones, turning that into a typedef instead of the actual types would just be pajeet tier thinking

>C++11 and newer has type inference, so no, that's not given.
Speaking of pajeet, didn't you read where I said 'assumed'? Last I checked that has a meaning similar to 'not always given'

>That map specification is regarded as a specific type too
OK? I was talking about the types used in the map but whatever, this is what I get for posting on a curry infested board
>>
>>58291752
Okay, so your argument is basically "based on the assumption that the types are more used than the map and if you disagree with that assumption you're a pajeet".

Got it. High quality post, anon.
>>
>>58291491
>If you're refusing C++ idioms, why even bother using C++?

You know, programming idioms are like bacon, as in too much causes cancer. If you program in a language that requires too many idioms, it's cancer. However, with C++ it's the community and the standard consortium that are cancer, as they encourage an idiotic amount of them. Not to say that the C-with-classes side of the spectrum is better.

>STL containers and RAII and exceptions?
For a big part STL containers and std functions. RAII is a little overrated, Jon Blow was right about that one. It should be about memory only. And exceptions in C++ are mostly unpleasant, so mostly not.

For a little part the hope that they might add modules in my life time, something they should have done from the beginning or at least from C++11 on.

However, the significant reason is that the amount of just-werks quality libraries and ecosystem for C++ is bigger. Two examples:
- Take a look at many smaller open sores C libraries. Many of them implement dynamic arrays aka std::vector, but many do it the bad way, without capacity.
- There is no equivalent to boost. APR and GLib, the best options, can't compete and APR is ridiculously underdocumented.
>>
>>58291945
RAII is GOAT compared to "defer" bullshit.

Rust is the language of the future and it's all about RAII.
>>
>>58286940
Never use printf or scanf, I know you can use cout and cin but the alternatives look so much cleaner imo.
>>
>>58292048
I ridicule golang as the next one, anon.
But let's be honest, RAII is only somewhat decent in Rust because it's built-in. I wouldn't mind a "scoped" keyword that just cares about memory.
>>
>>58286951

Answer is simple: _getch(); to prevent console window from closing after program is finished.
Thread posts: 47
Thread images: 2


[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.