#questions i have before my midterm
485 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
const parameters can bind to non-const arguments at call site
the const enforces that the function cannot modify the object, not that the object must be const in the first place
since this is for a midterm... you're asking all these questions, but do the answers we provide make sense? or do you simply intend to remember them by heart and regurgitate them for the exam?
they make sense
i mean
its not like their asking exactly
what im asking
i just need the concept
not asking that in a provocative way, sorry if that's how it sounded, but I'd rather give more lengthy explanations if need be, so that you'll have an easier time 😛
i had an idea already for that question since i asked it that way
juts needed to confirm
alright cool 👍
also memorizing seems harder
it is
at least for me too
it's okay to have to remember things because you can't yet exactly make sense of why things are the way they are
but I like it to make sense in my mental model so that I don't need to remember and instead reason my way back to the answer
void print() const
{ cout << year << "/" << month << "/" << day << endl; }
};
why is this legal
what does const do after the bracket
const qualified
ensures this class method can be called on a constant instance of that class
and that it cant modify class member variables unless they are marked as mutable
class A {
public:
void foo() {}
}
const A instance{};
instance.foo(); // wont compile, foo isnt const qualified and instance is const
yes and normal instances too
alr
got it
they have it in notes
wanted to confirm
what does "surprise" mean?
i get how the code works
if a class member variable is marked as mutable, it can be modified within const functions:
class A {
mutable int mut{};
int non_mut{};
public:
void foo() const {
mut = ...; // will compile, mut is a mutable member
non_mut = ...; // wont compile, non_mut is treated as const
}
}
const A instance{};
instance.foo();
oh wow
where do u see surprise
oh
just talking about explicit keyword
to avoid implicit conversions by accident/surprise
Not "let const objects call it", but "can be called on const objects"
Yes, it's called "array decay to pointer" in this specific instance and it can be performed as an implicit conversion
no, its happening within print_word
no as in thats not where the image is trying to point out
print_word takes a Word instance, yet its passing in a string and implicitly converting it to a Word instance
yeah
Right my bad, reading skills bad 
so if u mark the constructors as explicit it wont allow the implicit conversion, must be explicitly specified
so i put explicit like
let me edit
before the consturcotr
ok nvm i foudn exmaple
explicit Word(const char* s)
ok next
what is object returned by value
means a copy
copy?
class A{};
A foo() {
A instance{};
// do some stuff with instance
return instance;
}
returns by value
return by reference ```cpp
class A{};
A& foo() {
static A instance{};
// do some stuff with instance
return instance;
}
are there any cases where you wouldnt use mil
and use assigment instead
except for like creating new memory
ig
mil?
member initializtion lists
3rd question
what exactly is virtual
what does it accomplish
ima go to bed now
if anyone can answer these 3 pls do
ill respond tmr
this just seems like a keyword for smth
idkwhat it evne does
a keyword
polymorphism
Example:
;compile -Wall -Wextra
#include <iostream>
// since this class has a pure virtual function it's an abstract class and we can't create an instance of it
struct Animal {
virtual void name() { std::cout << "unknown animal\n"; } // virtual function with default implementation - we **can** override this in a subclass
virtual void sound() = 0; // pure virtual function - we have to override this in every subclass
};
struct Cow : Animal {
// note that the 'override' keyword is optional but recommended for readability
void name() override { std::cout << "Cow\n"; }
void sound() override { std::cout << "Moo\n"; }
};
struct Pig : Animal {
void name() override { std::cout << "Pig\n"; }
void sound() override { std::cout << "oink\n"; }
};
struct UndiscoveredBird : Animal {
void sound() override { std::cout << "jiiiii\n"; }
// note how here we didn't override the 'name' function
};
int main() {
Cow cow{};
Pig pig{};
UndiscoveredBird bird{};
Animal& a_cow = cow;
Animal& a_pig = pig;
Animal& a_bird = bird;
a_cow.name(), a_cow.sound();
a_pig.name(), a_pig.sound();
a_bird.name(), a_bird.sound();
}
Cow
Moo
Pig
oink
unknown animal
jiiiii
Virtual functions implement runtime polymorphism
In object-oriented programming such as is often used in C++ and Object Pascal, a virtual function or virtual method is an inheritable and overridable function or method that is dispatched dynamically. Virtual functions are an important part of (runtime) polymorphism in object-oriented programming (OOP). They allow for the execution of target fun...
In programming language theory and type theory, polymorphism is the use of a single symbol to represent multiple different types.
In object-oriented programming, polymorphism is the provision of a single interface to entities of different types. The concept is borrowed from a principle in biology where an organism or species can have many diffe...
The function (one of many with the same name) is selected at run time, based on the type of the object.
in the convoluted cases where you can't, there's probably a way that you can rearrange your code so that you can use them
so in essence, no, there are no practical cases where you wouldn't use a member init list
no this is fine, all things used here are properly defined
read chapters 24 and 25 here https://www.learncpp.com/
But what happens when I call the function
Which one does it use
B b;
b.f(); // calls B::f() on b
D d;
d.f(); // calss D::f() on d, which itself ends up calling B::f() on d
#include <iostream>
using namespace std;
class A {
public:
A(int n): x(n) {}
void print() {
cout << x << endl;
}
private:
int x;
};
void fun(const A obj) {
obj.print();
}
int main() {
A objA {10};
fun(objA);
return 0;
}
what is the error here
is it the A objA {10};
;compile cpp #include <iostream> using namespace std; class A { public: A(int n): x(n) {} void print()const{ cout << x << endl; } private: int x; }; void fun(const A obj) { obj.print(); } int main() { A objA {10}; fun(objA); return 0; }
10
;compile
<source>: In function 'void fun(A)':
<source>:13:12: error: passing 'const A' as 'this' argument discards qualifiers [-fpermissive]
13 | obj.print();
| ~~~~~~~~~^~
<source>:6:8: note: in call to 'void A::print()'
6 | void print() {
| ^~~~~
Build failed
A::print method needs to be const-qualified
or change the function signature of void fun(const A obj) to void fun(A obj)
is this compilation or runtime error?
does compiler detect this at start
also for this
#include <iostream>
using namespace std;
class D {
private:
int d;
public:
D(int n) : d(n) {}
D& decrement() {
d--;
return (*this);
}
D fun1(D& other) {
return (d > other.d ? decrement() : other.decrement());
}
D& fun2(D& other) {
return (d < other.d ? decrement() : other.decrement());
}
void print() const {
cout << d << endl;
}
};
int main() {
D n1(3), n2(1), n3(5);
n1.fun1(n2).fun2(n3);
n1.print();
return 0;
}
what does n1.fun1(n2).fun2(n3); do
i figured it out
@sturdy oriole Has your question been resolved? If so, type !solved :)
how do i know what this does
g++ -std=c++11 -fno-elide-constructors SQ-order-ctor-dtor.cpp -o SQ-order-ctor-dtor
man
what the hell is makefile why are they testing it
did you read or otherwise follow your course at all during the semester 
also when is your midterm exam
tmr
they explained it for the lab
but it was really annoying so i just compiled the main
#include <iostream>
using namespace std;
class A {
int a;
public:
A(int a = 0) : a(a) { cout << "AC1" << endl; }
A(const A& a) : a(a.a) { cout << "AC2" << endl; }
~A() { cout << "AD" << endl; }
};
class B {
int b;
public:
B(int b) : b(b) { cout << "BC1" << endl; }
B(const B& b) : b(b.b) { cout << "BC2" << endl; }
~B() { cout << "BD" << endl; }
};
class C {
A a;
B b;
int c;
public:
C() : c(10), a(A()){ cout << "CC" << endl; }
~C() { cout << "CD" << endl; }
};
class D {
A a{10};
B b{20};
C c;
public:
D() { cout << "DC" << endl; }
~D() { cout << "DD" << endl; }
};
int main() {
cout << "Beginning of main" << endl;
D obj;
D obj2;
cout << "End of main" << endl;
}
this function
AC1
BC1
AC1
AC2
AD
BC1
BC2
BD
CC
DC
End of main
DD
CD
BD
AD
BD
AD
they gave this as output
when is bc2 hpapening
i do not understand
the output seems to be only half as long as it should be
so I'll assume the code that produced this had only D obj; and not D obj2;
but anyway if you understand why you see AC2 you should also understand why you see BC2
oh yeah in here it's D obj2(); and not D obj2;
D obj2; declares an object of type D named obj2 and calls its default constructor
D obj2(); declares a function named obj2 which takes no parameter and returns an object of type D
the former would produce what D obj; already does (and which you posted), the latter simply states "this is a function that exists" and does nothing else
yeah i get ac2
but where is bc2
being copied
i dont see it
wait
look at function agian
there was extra line there
mb
okay, now I think this shouldn't compile
B has no default constructor and is not initialized with parameters that match one of its constructors
why is bc1 there then
rn my order of what i see is
creates d
AC1
BC1
creates c
AC1 BC2
then AC2 AD
right???
theres n o bc1
im tirpping
- C is default constructed
- first, c is initialized
- then, A is default constructed (A1) and the result is fed into the copy constructor of A (A2)
- only then, B is being default constructed, for which the only eligible constructor is
B(const B& b = 0), so it gets called with a default argument constructed from 0- the argument type is still
const B&though so somehow0needs to be turned into aB- THIS is what calls the B1 constructor of B which takes an int
- the resulting object is the actual argument to the copy constructor of B, which outputs B2
- the argument type is still
well the bullet points are all fucked up but you get the idea
note that this only happens because the file is compiled with -fno-elide-constructors
i have no idea what that does
otherwise, any sane compiler probably merges the constructor calls without generating temporary copies, and is obligated to do so in C++17 and later
okok so it runs default on b which then creates a const b from 0
(this is compiled in c++11 according to the command line that you posted though, compilers still probably eliminated the extraneous constructor calls)
it doesn't run the default constructor on B, there is no default constructor on B
yeah\
it runs the copy constructor with a default argument
i mean the copy thing
yeah
so the copy runs the b(0) constructor
so its bc1 bc2 then deletes the b(0) constructor
I might seem nitpicky but the distinction will probably be important in your midterm
yeah
i hate exams so much for cs
literlaly makes no sense
0 application in real life
will never help me
does not "delete the b(0) constructor" but "destroys the object which was constructed by b(0) because it was created only for the copy constructor call and is no longer needed as part of this call (since it's done)"
ye
also last one
for the destructor order
why does it call class "C" destructor first
believe it or not this is actually really useful knowledge when you write a lot of C++
this sentiment I agree with yeah
D is the first destructor that is being called, and when the destructor body runs out, then the members are destroyed in reverse order of that in which they were initialized
and then the same thing happens
in each of them, destructor body first, member destructors in reverse order then
(the order of initialization for class members matches exactly the order in which they are declared)
ok
they have this weird thing too where virtual functions are thought
but not adts
because they havent reached it
but they will still be in the exam
the adts wont
but virtuals will
but both of them are tied to each other
all i know is that you can override virtuals
thats all
This is a pretty good example to work out
Note that references are being used in main, and that's important
You can also read the chapters of learncpp that I linked above
also is melvor
that runescape idle game
i saw it once i think when i was lookingm for idle gmaes
i will be reseraching lambda expressions now sincei dont understand them
Yes
you mentioned here they dont use copy elison
what would have been differnet if they were allowed to use copy elison
Not sure about B (I think it would have remained there; worth checking) but you would see no copy constructor call for A
Most compilers did it before C++17, it's guaranteed to happen from C++17 onwards
That is, class instances that are move/copy-constructed from temporaries are instead constructed directly using the argument that said temporaries are constructed from
(roughly)
so the ac2 ad wouldnt exist and it would just be ac1?
Yes
It does, but the compiler detects that a is copy constructed from a temporary A instance and instead constructs a just like it would the temporary
The temporary isn't involved anymore
ic
so no ac1?
wait no
no ac2
cause the ac2 part is the useless copying part
oh my god this hurts my head
#include <iostream>
using namespace std;
int main()
{
int a = 1, b = 1, c = 1;
auto f1 = [a, &b, &c] () mutable {
cout << a << " " << b << " " << c << '\n';
auto f2 = [a, b, &c] () mutable {
cout << a << " " << b << " " << c << '\n';
a = b = c = 4;
};
a = b = c = 3;
f2();
};
a = b = c = 2;
f1();
cout << a << " " << b << " " << c << '\n';
}
;format
;format
#include <iostream>
using namespace std;
int main()
{
int a = 1, b = 1, c = 1;
auto f1 = [a, &b, &c]() mutable {
cout << a << " " << b << " " << c << '\n';
auto f2 = [a, b, &c]() mutable {
cout << a << " " << b << " " << c << '\n';
a = b = c = 4;
};
a = b = c = 3;
f2();
};
a = b = c = 2;
f1();
cout << a << " " << b << " " << c << '\n';
}
Powered by godbolt.org
if its excecuted when f2(); is called
why does it not capture 3 3 3
am i stupid
like a=b=c=3;
so all values are 3
then it should capture all 3 right?
or because c is reference does it get the global value
from main
;compile
1 2 2
1 2 3
2 3 4
thought it would be
1 2 2
3 3 3
2 3 4
ur modifying them after they have been captured
the capture happens the moment u write it
unless its a capture by reference, it will capture by value aka copy the value
thats why the first print says 1 2 2, 1 was copied when it was 1, the rest were references and the references memory was updated
capture happens when written yes
u can easily understand why:
have u learnt about operator overloading
have u learnt about functors
what
its where a class overloads the () operator
#include <iostream>
class A {
public:
int operator()(/*parameters*/) {
return 69;
}
};
int main() {
A instance{};
std::cout << instance();
}
;compile
<source>: In function 'int main()':
<source>:10:8: error: 'cout' is not a member of 'std'
10 | std::cout << instance();
| ^~~~
<source>:1:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | class A {
Build failed
gg
forgot include
;compile
69
oohg
then they use auto in questions
amazing
im going to shank my professor
what does mutable do to lambda?
i assume it makes it so we can change the parameters?
int a{};
auto lambda = [a](){ return a; };
// the lines above are equivalent to the auto generated code below:
class lambda
{
int a;
public:
lambda(int& _a) : a{_a} {}
int operator()() const {
return a;
}
};
lambda lambda_instance {a};
lambda_instance(); // whenever u want to call the lambda
and if u remember i told u that constant class methods can not modify the member variables
mutable on a lambda is the same as making the member variables of the generated lambda structure mutable ||it just removes the const qualification though!||
no because the functor is const and thats what gets called when u do lambda()
that class is what the compiler generates
a lambda is a functor
and if u were to capture a by reference, the member variable would change from int a; to int& a;
ok
so if i were to like
#include <iostream>
using namespace std;
int main()
{
int a = 1, b = 1, c = 1;
auto f1 = [a, b, c](){
cout << a << " " << b << " " << c << '\n';
auto f2 = [a, b, c]() {
cout << a << " " << b << " " << c << '\n';
a = b = c = 4;
};
a = b = c = 3;
f2();
};
a = b = c = 2;
f1();
cout << a << " " << b << " " << c << '\n';
}
;compile
<source>: In lambda function:
<source>:10:15: error: assignment of read-only variable 'b'
10 | a = b = c = 4;
| ~~^~~~~~~
<source>: In lambda function:
<source>:12:7: error: assignment of read-only variable 'a'
12 | a = b = c = 3;
| ~~^~~~~~~~~~~
Build failed
;compile
https://cppinsights.io/s/84811e3d take a look at this btw
#include
int main()
{
int a{};
auto first_lambda = a{ return a; };
/*---------
<source>: In lambda function:
<source>:10:19: error: assignment of read-only variable 'c'
10 | a = b = c = 4;
| ~~^~~
<source>: In lambda function:
<source>:12:15: error: assignment of read-only variable 'c'
12 | a = b = c = 3;
| ~~^~~
Build failed
ok
im looking at it
what am i supposed to look at
oh
nvm
its all just classes
wow
yep, as shown here
that should help u visualize captures by value, by reference and the mutable keyword on lambdas etc
const by default withoit mutable
the class instance gets created the moment u define the lambda, but the operator() is only called when u want to, this is why it holds the original values copied by value
i have achieved sentience
i will sleep better before my exam
that website is really cool
it is
i was gone
he is ogne
pretty much this
oh
cant remember exactly
i saw a question where it had like 3 classes
the base
the derived
and derived from derived
and the 2nd layer had a virtual function but the first one didnt(both had same name)
and how does that work
i cannot find the question
unnecessary copy avoiding aka return value optimization
does the 2nd layer function override the base class
idk provide the code
ill go take a nap while ur at it
alright
#include <iostream>
using namespace std;
class Base
{
public:
Base() { cout << "Base's constructor\n"; }
~Base() { cout << "Base's destructor\n"; }
};
class Derived : public Base
{
public:
virtual Derived() { cout << "Derived's constructor\n"; }
~Derived() { cout << "Derived's destructor\n"; }
};
class Derived2 : public Derived
{
public:
Derived() { cout << "Derived's constructor\n"; }
~Derived() { cout << "Derived's destructor\n"; }
}
int main()
{
Base* p = new Derived;
delete p;
}
something like tihs
idk i may have been tripping
cause my cmpiler doesnt like it
virtual constructors don't exist
and classes cannot have constructors that are not their own
(Derived2 can only have Derived2 constructors)
the destructor needs to be virtual in any derived class that will be managed through its base class
otherwise you expose yourself to nasty stuff
so the base class destructor has to be the virtual one
no, the base class destructor is fine
the derived classes' destructors aren't
(and Derived2 still cannot have a destructor for Derived, it makes no sense)
oh yeah
i just kinda copoy pasted it
lemme
uh
#include <iostream>
using namespace std;
class Base
{
public:
Base() { cout << "Base's constructor\n"; }
~Base() { cout << "Base's destructor\n"; }
};
class Derived : public Base
{
public:
Derived() { cout << "Derived's constructor\n"; }
virtual ~Derived() { cout << "Derived's destructor\n"; }
};
class Derived2 : public Derived
{
public:
Derived2() { cout << "Derived2's constructor\n"; }
~Derived2() { cout << "Derived2's destructor\n"; }
};
int main()
{
Base* p = new Derived;
delete p;
}
so this legal
so the derived 2 can overide the derived 1 thing
there is not overriding taking place here
overriding is a thing for regular member functions
what do you think is happening?
there are constructor and destructor calls involved and they print to the output so surely something observable must be happening
maybe try to play around with this code on your computer or on compiler explorer
Try copying the code and running it, then remove the virtual keyword and see what's different
see what happens when you remove virtual from Derived's destructor declaration
lol you sniped me 
Base's constructor
Derived's constructor
Derived's destructor
Base's destructor
cool
now can you try to guess what would happen without virtual
if you can't, now is a good time to try it out
Base's constructor
Derived's constructor
Base's destructor
Also, try changing the line to Derived* p = new Derived then try both with virtual and without again
Look at what's different
why doesnt it do derived destructor
oh wait
the pointer is for base
ok
so virtual makes it so the pointer deletes the correct class?
yes, exactly
and as you very correctly noted, it's a combined effect of both having virtual functions and using them through a pointer or a reference
okay im a test the double virtual function thing
#include <iostream>
using namespace std;
class Base
{
public:
Base() { cout << "Base's constructor\n"; }
~Base() { cout << "Base's destructor\n"; }
virtual void f() { cout << "bals"<<endl; }
};
class Derived : public Base
{
public:
Derived() { cout << "Derived's constructor\n"; }
~Derived() { cout << "Derived's destructor\n"; }
void f() override{ cout << "bals1"<<endl; }
};
class Derived2 : public Derived
{
public:
Derived2() { cout << "Derived2's constructor\n"; }
~Derived2() { cout << "Derived2's destructor\n"; }
void f() override { cout << "bals3"<<endl; }
};
int main()
{
Base* p = new Derived;
p->f();
delete p;
}
this broken?
i guess i cant have 2nd layer virtual void
why couldn't you
Idk it don’t compile
;compile
Base's constructor
Derived's constructor
Base's destructor
;compile
Base's constructor
Derived's constructor
balsBase's destructor
what
;compile
Base's constructor
Derived's constructor
bals1
Base's destructor
;compile
Base's constructor
Derived's constructor
Derived2's constructor
bals3
Base's destructor
;compile
Base's constructor
Derived's constructor
bals1
Base's destructor
class A {
int* p;
public:
A() { p = new int; }
~A() { delete p; }
};
int main() {
A obj1, obj2;
obj1 = obj2;
}
why is tus double free
;format
class A {
int* p;
public:
A() { p = new int; }
~A() { delete p; }
};
int main()
{
A obj1, obj2;
obj1 = obj2;
}
Powered by godbolt.org
what does obj1=obj2; do exactly
does it not delet eobj1
why would that cause a double free
copies the value of obj2 into obj1
ok
resulting in 2 frees of the same pointer and 0 frees of the first pointer
obj1 = obj2 ===== obj1.p = obj2.p
obj2.p was copied into obj1.p look at the code here
int* obj1_p = new int();
int* obj2_p = new int();
obj1_[ = obj2_p; // obj1_p and obj2_p hold the same value now, this is a copy of the pointer
delete obj1_p; // these 2 have the same value:
delete obj2_p;
how do you know this
is it like default
for classes to copy all member values?
the whole class only has the pointer
i thought it was creating a new class
its a copy
these are called special member functions:
- constructor
- destructor
- copy assignment (copy operator / copy assignment operator)
- copy constructor
- move assignment (move operator / move assignment operator)
- move constructor
the compiler follows a set of rules to determine which of these need to be defaulted and implicitly defined by the compiler
u can look up c++ special member function compiler rules
but in ur example the compiler defined the copy assignment
class A {
A() {}
~A() {}
// copy
A& operator=(const A& other) {}
A(const A& other) {}
// move
A& operator=(A&& other) {}
A(A&& other) {}
}
heres the code, following the same order
im just introducing relevant things to u so u dont just memorize why something happens instead understand why @sturdy oriole
ok
ur next lesson is probably gonna be move semantics or something similar
#include <iostream>
using namespace std;
class A
{
public:
void nonConstMemFunc() { }
void constMemFunc() const { }
const A getConstObj() { return *this; }
const A& getConstRefObj() { return *this; }
};
int main()
{
const A constObj;
constObj.nonConstMemFunc(); /* Error: Yes / No */
constObj.constMemFunc(); /* Error: Yes / No */
A nonConstObj;
A nonConstObj2 = nonConstObj.getConstObj(); /* Error: Yes / No */
A nonConstObj3 = nonConstObj.getConstRefObj(); /* Error: Yes / No */
A& nonConstRefObj1 = nonConstObj.getConstObj(); /* Error: Yes / No */
A& nonConstRefObj2 = nonConstObj.getConstRefObj(); /* Error: Yes / No */
const A constObj2 = nonConstObj.getConstObj(); /* Error: Yes / No */
const A constObj3 = nonConstObj.getConstRefObj(); /* Error: Yes / No */
const A& constRefObj1 = nonConstObj.getConstObj(); /* Error: Yes / No */
const A& constRefObj2 = nonConstObj.getConstRefObj(); /* Error: Yes / No */
A& const mystery = nonConstObj.getConstObj(); /* Error: Yes / No */
return 0;
}
;format
;format
#include <iostream>
using namespace std;
class A {
public:
void nonConstMemFunc() { }
void constMemFunc() const { }
const A getConstObj() { return *this; }
const A& getConstRefObj() { return *this; }
};
int main()
{
const A constObj;
constObj.nonConstMemFunc(); /* Error: Yes / No */
constObj.constMemFunc(); /* Error: Yes / No */
A nonConstObj;
A nonConstObj2 = nonConstObj.getConstObj(); /* Error: Yes / No */
A nonConstObj3 = nonConstObj.getConstRefObj(); /* Error: Yes / No */
A& nonConstRefObj1 = nonConstObj.getConstObj(); /* Error: Yes / No */
A& nonConstRefObj2 = nonConstObj.getConstRefObj(); /* Error: Yes / No */
const A constObj2 = nonConstObj.getConstObj(); /* Error: Yes / No */
const A constObj3 = nonConstObj.getConstRefObj(); /* Error: Yes / No */
const A& constRefObj1 = nonConstObj.getConstObj(); /* Error: Yes / No */
const A& constRefObj2 = nonConstObj.getConstRefObj(); /* Error: Yes / No */
A& const mystery = nonConstObj.getConstObj(); /* Error: Yes / No */
return 0;
}
Powered by godbolt.org
ok
are the rules i state there correct
const object or reference cnanot be implicitly converted to non const reference
but the other implicit versions here are fine?
a const A& can bind to any kind of A
A& needs a non-const A
for a variable of type A, it depends on whether you have a copy constructor or what you're getting from a function call, etc.
A& const is fun
but const a& cannot convert to a&
I’m dead
70 maximum
Most likely 55
Thanks for all the help fellas
Prob would’ve been 30 without the help
@sturdy oriole Has your question been resolved? If so, type !solved :)
the terminology is the other way around
a reference const a& binds to whatever it is initialized with
you bind references to things
oh
!solved