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
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.
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.
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....
copy constructor is reasonable tho
but without a move constructor, the compiler won't be able to optimize things as well, but whatever
https://gustedt.wordpress.com/2025/01/06/simple-defer-ready-to-use/
hmmm
https://gustedt.wordpress.com/2026/02/15/defer-available-in-gcc-and-clang/
hmmmmmmm
I mean like. not the most convenient, buuuuttttt
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??
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
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
yeah it seems there are some DSPs where this is the case
Apparently, this one has 32-bit char, and, as a consequence,
sizeof(int)==sizeof(char)==1
>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
Pass by value cannot accept a parameter that is an expression.
...what?
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
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)
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.
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
using namespace std;
STOPPPPP
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)
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)
"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...
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?
I have cppreference open right now. it literally says
Inserts a newline character into the output sequence
osand flushes it as if by callingos.put(os.widen('\n'))followed byos.flush().
what.
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
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)
oh boy, time to learn what a struct and a class is!
(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
I love learning about what arraylists are
??? 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)
why the fuck are we calling everything an "ADT"
in C++ they don't have an array list, they have something called vector
?????
in C++, std::vector is an array list??
how are we managing to explain linked lists in a way that is confusing
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?
favourites list ADT
what?
are we just making shit up now
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
???
@solonovamax deadass HORRIBLE ux design ðŸ˜
things should be kept at fixed positions!
@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.
@noisytoot imo C doesn't have strings, it has char arrays
char array != string