Conversation

just gonna make this a thread for any time I complain about smth my prof is doing/saying

mute this thread if you don't wanna see it

1
0
0
p1 = new int;

What.

stop. now.

1
0
1

"dangling pointers"

this is why you use smart pointers :)

1
0
1

not from my prof but from cppreference.org

double* p = new double[]{1, 2, 3}; // creates an array of type double[3]
auto p = new auto('c'); // creates a single object of type char. p is a char*

auto q = new std::integral auto(1); // OK: q is an int*
auto q = new std::floating_point auto(true) // ERROR: type constraint not satisfied

what the fu-

why does it allow this.

1
0
0
long thread, complaining about shit my profs say
Show content

also, my assignment has incredible requirements like:

All data members of user-defined class type must be of pointer type.

he explained this as "any data member and any variable and any assignment has to be pointers"

like. What.

1
0
0
long thread, complaining about shit my profs say
Show content

or

All classes must implement a correct copy constructor, assignment operator, and stream insertion operator

like. what. why does it need an assignment operator (not a move constructor???) and a stream insertion operator.
using std::cout is cringe, use fmt::print/fmt::println (or std::print/std::println (or a logger which uses either of these)) and then implement a custom formatter.

also, not Everything needs a way to be formatted to stdout....

1
0
0
long thread, complaining about shit my profs say
Show content

copy constructor is reasonable tho

but without a move constructor, the compiler won't be able to optimize things as well, but whatever

1
0
0
long thread, complaining about shit my profs say
Show content

why does he even need to explain

const int * const x = &foo;

this is quite easy to understand. constant pointer to a constant value. that is literally just how you read it?? why does this need an explanation??

1
0
0
long thread, complaining about shit my profs say
Show content
void increase (void* data, int psize){
if ( psize == sizeof(char) ){
char* pchar; pchar=(char*)data; ++(*pchar); }
else if (psize == sizeof(int) ){
int* pint; pint=(int*)data; ++(*pint); }
}

unless I'm mistaken, according to the spec sizeof(char) can equal sizeof(int) (though, in practice, there are not really any systems where this is true, afaik)

also, I have not adjusted the formatting from the lecture notes presentation pdf. that's just exactly what he wrote

1
0
0
long thread, complaining about shit my profs say
Show content

it seems that Texas Instruments C54x DSPs have 16 bit chars, I wonder if they use 16 bit ints? a quick search only gave me datasheets and I'm too lazy to look into it further

1
0
0
long thread, complaining about shit my profs say
Show content

yeah it seems there are some DSPs where this is the case

https://web.archive.org/web/20140818152814/http://objectmix.com/c/392230-likelihood-char_bit-==-8-a.html

Apparently, this one has 32-bit char, and, as a consequence,

sizeof(int)==sizeof(char)==1
1
0
0
long thread, complaining about shit my profs say
Show content

>section in the notes titled "smart pointers"
>arrives at it
>"so we're not going to talk about smart pointers. we're going to skip this section"

NOOOOO

1
0
0
long thread, complaining about shit my profs say
Show content

Pass by value cannot accept a parameter that is an expression.

...what?

1
0
0
long thread, complaining about shit my profs say
Show content

By Reference:

  • Drawback: cannot pass NULL , as a reference cannot be NULL

what? how is this a drawback? this is a good thing?
and if you need an optional value, std::optional exists

1
0
0
long thread, complaining about shit my profs say
Show content

for the pass by value, is he thinking of pass by reference..?

because iirc if you initialize struct or whatever passed to smth that takes a reference, iirc the reference will go out of scope and not be valid (I could be misremembering this)

1
0
0
long thread, complaining about shit my profs say
Show content

C++ provides following two types of string representations:

  • C-style character strings
  • string class type introduced with Standard C++

wrong! a char array is not a string. it is a char array.

1
0
0
long thread, complaining about shit my profs say
Show content

Many libraries would define their own string type

back in like the fucking 90s?

ignoring glib (& any libraries that need a string with known length at compile time for funny template stuff), basically everyone just uses std::string (at least afaik, I could be mistaken, but I don't see it that often)
well, maybe some really large projects have their own string type. like I could see chromium doing that or smth

2
0
0
long thread, complaining about shit my profs say
Show content
using namespace std;

STOPPPPP

1
0
0
long thread, complaining about shit my profs say
Show content

I have another prof who actually knows what he's doing tho for a course where we look at multiple different languages (starting with C, then python, then clojure, then erlang)

1
0
0
long thread, complaining about shit my profs say
Show content

NOOOOOO he mentioned make, said "the syntax is really obscure so usually we use a generator", then mentioned cmake and didn't mention something better like meson </3

(though he did say we're not going to be using either, and instead just invoking the command directly)

1
0
0
long thread, complaining about shit my profs say
Show content

"when printing to a stream you can use the c-style \n or you can use std::endl"
do not use \n, it doesn't flush the stream...

1
0
0
long thread, complaining about shit my profs say
Show content

he asks what the difference is between \n and std::endl
I respond that it flushes the stream

he says "no"

?????

that is LITERALLY what the difference is?

1
0
0
long thread, complaining about shit my profs say
Show content

I have cppreference open right now. it literally says

Inserts a newline character into the output sequence os and flushes it as if by calling os.put(os.widen('\n')) followed by os.flush().

what.

1
0
0
long thread, complaining about shit my profs say
Show content

he just said that calling .open() on ofstream will cause the file to be locked

I don't think that's the case..?
but I could be wrong about that one

1
0
0
long thread, complaining about shit my profs say
Show content

I think with pointers you usually define them with, uh, a star sign

(mind you, this was a TA and they probably mispoke, I just found it funny that they said "usually" here lol)

1
0
1
long thread, complaining about shit my profs say
Show content

oh boy, time to learn what a struct and a class is!

1
0
0
long thread, complaining about shit my profs say
Show content

(talking about header files in C++)

As opposed to Java classes, C++ allows to have class declarations that do not include the definition of the functions it encapsulates.
This enables the possibility to separate the class declaration from its implementation code, which provides the implementation of the member functions of a class.

I mean.. I guess it provides that possibility?
you can do this in java already with an interface though...

but like.. the main reason header files exist is because they come from a time when computers weren't powerful enough to be able to hold everything in memory and do multiple passes during the compilation process. they weren't really added for the purpose

1
0
0
long thread, complaining about shit my profs say
Show content

I love learning about what arraylists are

1
0
0
long thread, complaining about shit my profs say
Show content

??? my teacher just claimed that in java, ArrayList has a method .get(integer i)

no? integer is not a class that exist? the signature is #get(int)

1
0
0
long thread, complaining about shit my profs say
Show content

why the fuck are we calling everything an "ADT"

1
0
0
long thread, complaining about shit my profs say
Show content

in C++ they don't have an array list, they have something called vector

?????

in C++, std::vector is an array list??

1
0
0
long thread, complaining about shit my profs say
Show content

how are we managing to explain linked lists in a way that is confusing

1
0
1
long thread, complaining about shit my profs say
Show content

That is, in a list, each position b will always be after a position, a, and before a position c, except when b is the first or last position in the list

that is... a property of any finite sequence of integers?

1
0
1
long thread, complaining about shit my profs say
Show content

favourites list ADT

what?

1
0
0
long thread, complaining about shit my profs say
Show content

are we just making shit up now

1
0
0
long thread, complaining about shit my profs say
Show content

he is explaining how this might be used with an example of a GUI which has a dropdown menu with 20-30 entries
his suggestion is that the application should track how often each menu item is pressed, and then only show the top 5 most pressed items

???

1
0
0

@solonovamax deadass HORRIBLE ux design 😭

things should be kept at fixed positions!

0
0
0
re: long thread, complaining about shit my profs say
Show content

@solonovamax IVAN uses its own string type for some reason (in C++). Also, a null-terminated char array is a string, otherwise C doesn’t have strings.

1
0
1
re: long thread, complaining about shit my profs say
Show content

@noisytoot imo C doesn't have strings, it has char arrays
char array != string

1
0
0
re: long thread, complaining about shit my profs say
Show content
@solonovamax char array != string, but (C) strings are a subset of char arrays (specifically null-terminated char arrays). confusingly, the C standard library also has some functions that operate on null-padded character sequences (stncpy, stpncpy, strncat, strndup) which are char arrays but are not strings, despite those functions being named as if they operate on strings
1
0
0
re: long thread, complaining about shit my profs say
Show content
@solonovamax it's just not encoded into the type system (a string char* is the same type as a non-string char*) but C (or at least libc) definitely does have the concept of a string
0
0
0