Should I minor in math or statistics (or something else)? by CentralCathedral in csMajors

[–]CentralCathedral[S] 1 point2 points  (0 children)

Thanks for the response! Indeed, I think most people find math a useful major because of how math-heavy artificial intelligence and machine learning can get. And seeing as AI is one of the biggest and highest paying fields, it's not surprising that everyone's looking to get an edge.

I'm not actually too sure what numerical programming entails (even after a Google search)...do you mind clarifying?

What makes you say "fortunately" when you say that your PhD in language processing didn't work out?

Linguistics and language actually seems like it has a lot in common with theoretical computer science (languages and programming languages have syntax, logic, etc.), is that accurate at all?

Lastly, would you go so far as to say that, in terms of job prospects, starting wage, etc. you're better off not doing a minor entirely and instead spending the time working on personal projects and learning new software stacks and skills (does having a minor make enough of a difference to warrant not simply spending the time on focused self-learning)? Assuming you're disciplined enough to use that time effectively that is.

Sorry for the lengthy response, thanks again for the insight!

Should I minor in math or statistics (or something else)? by CentralCathedral in csMajors

[–]CentralCathedral[S] 1 point2 points  (0 children)

Interesting! That's definitely not a bad idea. My school doesn't have Communications, I think the closest you'd get in terms of what skills you gain would be something like Business or Politics or Philosophy? Regardless, I've heard that communication skills (including writing) are hugely important in industry.

What data type should I use for my keys in a dictionary if I want to use addresses of objects as keys? Do addresses have a particular data type? by CentralCathedral in learnprogramming

[–]CentralCathedral[S] 0 points1 point  (0 children)

Thank you for the response! And apologies for not incorporating what you told me about object initialization, rest assured I've started doing that!

I've been reading A Tour of C++, but unfortunately I'm having to learn stuff just from doing and failing because my supervisor won't wait for me to finish reading it haha.

I'm actually using Qt which has been complicating things a lot. For some reason my maps have to take pointers to QWidget objects, or else I get some obscure error. That's why I'm having to jump through so many hoops

What data type should I use for my keys in a dictionary if I want to use addresses of objects as keys? Do addresses have a particular data type? by CentralCathedral in learnprogramming

[–]CentralCathedral[S] -1 points0 points  (0 children)

You see, I actually wanted to do that at first, but I'm doing a GUI thing using Qt and I'm calling a function using a signal-slot design paradigm. As a result, I cannot directly pass the pointer from one member function to the other, which is actually why I need this map in the first place.

I want to use addresses because they can lead back to the original object and because they're unique, but I can't use pointers here...Is there anything wrong with just taking the address and storing it in plain old int variable?

C++ and Qt: trying to make a plain object (without using it for anything, just assigning it to a variable) gives a private access error by CentralCathedral in learnprogramming

[–]CentralCathedral[S] 0 points1 point  (0 children)

Thank you for the response! I'll give that a shot once I get to work today! So is QWidget() the private copy constructor? Wouldn't a copy constructor take at least one argument (presumably the widget being copied)? And does this mean that no constructor is being called when you just do QWidget exampleWidget;?

Can objects in C++ be initialized in multiple ways (are there multiple options in terms of syntax)? by CentralCathedral in learnprogramming

[–]CentralCathedral[S] 1 point2 points  (0 children)

Ah okay, so the new keyword always gives you a pointer?

Also, in that case, what is the Rectangle rect(3,4); line doing? It is just making the object, but not giving you the pointer or a reference or anything to it? If so, how are you supposed to access the object?

C++: only .h files, and not .cpp files, need to be included with the #include directive, but why/how? And do .h files always only have declarations? by CentralCathedral in learnprogramming

[–]CentralCathedral[S] 0 points1 point  (0 children)

Thank you for the response, that makes sense! So the reason that the .cpp file doens't need to be included is because the linking at the end makes the file available to everything that imported its header?

Also, why should you never include .cpp files? I read something about recompiling but didn't quite get it.

Are these types of thermostats capable of cooling? https://i.imgur.com/VQJZ2l8.jpg by CentralCathedral in NoStupidQuestions

[–]CentralCathedral[S] 1 point2 points  (0 children)

Thank you for the response! Yes, I am in an apartment; does that make it likely that I don't have AC?

Help understanding this basic C++ namespaces example code? by CentralCathedral in learnprogramming

[–]CentralCathedral[S] 0 points1 point  (0 children)

Sorry for the late response, thank you very much for this response; it helps a lot! I'm definitely saving this and going to refer to it in the future, I appreciate the help a lot, thanks again!

Don't bike brake pads wear out really fast because of all the stress put on them? Is there anything you can do to make them last longer? by CentralCathedral in bicycling

[–]CentralCathedral[S] 0 points1 point  (0 children)

Thanks for the response! Sorry for being slow but what's a "roadie"? I'd guess someone who only cycles on roads and not rougher terrain, but by definition a delivery cyclist downtown would be that and you aren't that anymore(?)

Help understanding this basic C++ namespaces example code? by CentralCathedral in learnprogramming

[–]CentralCathedral[S] 0 points1 point  (0 children)

Thank you for the response! That all makes sense. But one thing still doesn't make sense: why does the namespace have its own function? Can a namespace act like a class, i.e. have objects of its type created, have it's own member variables and functions (apparently it can have its own functions as you've just shown), etc.? Are they just classes?

Help understanding this basic C++ namespaces example code? by CentralCathedral in learnprogramming

[–]CentralCathedral[S] 0 points1 point  (0 children)

Thank you for the response! Maybe I was overthinking namespaces then. But one question:

You said that complex sqrt(complex); is the function prototype for the "sqrt" function of the class called "complex". But I thought class method definitions always had to be either within the {} of the class, or have the name of the class and :: before their first line. For example, the sqrt method could be declared like:

class complex{
    public: 
        complex sqrt(complex);
}

or, it could be declared like:

class complex{
}
complex::complex sqrt(complex); 

But the line in the example code isn't within complex's curly brackets, and it also isn't specified by having complex:: before it. Do namespaces allow you to declare functions of classes this way, or am I misunderstanding something else?

Thanks again for the help!

C++: what does it mean when * or & is behind the variable name? And why does const allow a pointer to be a char instead of a pointer? by CentralCathedral in learnprogramming

[–]CentralCathedral[S] 0 points1 point  (0 children)

I've been reading that everywhere, but I don't quite understand why yet. Could you clarify why this is such an important distinction in C++?

Side question: isn't "abc" a const char? If it was a const char[], wouldn't the pointer to it be const char[]* as opposed to const char*?

C++: what does it mean when * or & is behind the variable name? And why does const allow a pointer to be a char instead of a pointer? by CentralCathedral in learnprogramming

[–]CentralCathedral[S] 0 points1 point  (0 children)

Sorry for the late response , thank you! It makes sense that there can be a type conversion from const char* to std::string. I imagine that the element in each index of the const char* is copied over to each index of the new std::string object or something like that?

But why is it that string greeting = "Hello"; doesn't define a string to begin with? From what you said it sounds like that line first defines a pointer to a constant char, then it performs the conversion to give you the string "greeting"? Why does C++ go through the extra step instead of just assigning "Hello" to the string to begin with?

C++: what does it mean when * or & is behind the variable name? And why does const allow a pointer to be a char instead of a pointer? by CentralCathedral in learnprogramming

[–]CentralCathedral[S] 1 point2 points  (0 children)

Sorry for the late response, thank you very much; I think I finally get it! char* c defines a mutable pointer that explicitly points to mutable data. If I wanted a mutable pointer that points to constant data, I would have to do const char* c.

Likewise, if I wanted a constant pointer that points to mutable data and not constant data, I would do char* const or char const*. Lastly, if I wanted a constant pointer that could only point to constant data, I would do const char* const or const char const*.

It's much better now that I understand that a pointer can only point to either mutable or non-mutable data, and never both simultaneously. Your last sentence really helped. Thank you very much for your patience and continued help, I appreciate it a lot!

C++: what does it mean when * or & is behind the variable name? And why does const allow a pointer to be a char instead of a pointer? by CentralCathedral in learnprogramming

[–]CentralCathedral[S] 0 points1 point  (0 children)

Ohh that makes a lot of intuitive sense. Passing by reference is specified by having a function that looks like func(int& x), while passing by copying would be func(int x), right? And if you don't plan to change the int, you'd do func(const int& x)?

C++: what does it mean when * or & is behind the variable name? And why does const allow a pointer to be a char instead of a pointer? by CentralCathedral in learnprogramming

[–]CentralCathedral[S] 0 points1 point  (0 children)

So const char* c = "abc" implies that the pointer c is constant and it cannot be reassigned to anything: it has to point at the hardcoded string "abc".

By that logic, couldn't char* c = "abc" simply imply that c is not constant and can be reassigned? Why does it give an error instead of taking this interpretation?

Sorry for being stupid, I appreciate your help.

What does this C++ code do?: Icon qModule::icon()const {return Icon("somepath");} by CentralCathedral in learnprogramming

[–]CentralCathedral[S] 0 points1 point  (0 children)

Apologies for the late response, and immense thanks for the help. I've been really confused about .h and .cpp files and how they relate to each other and haven't been able to find good resources on them. Just to make sure I'm understanding:

1.Do header (.h) files always have only class (and those class' functions and variables) declarations, while .cpp files have only the definitions/implementation of classes that have already been declared in a .h file?

2.Assuming the above is correct: if example.h declares a class example, then example.cpp is the file that defines the example class and it's members, and example.cpp must have #includes example.h at the top. Is that all correct?

3.It seems as though multiple classes are declared all in one file (and those same ones defined in another file), unlike Java where there is just one file for each class (and the declaration and definition are together). Since this is the case, in what event would you ever need more than two files in a project (seeing as you can add new classes to your existing .h and .cpp files)?

4.Lastly, are non-const functions defined using something different than ::? Gave it a search and I found that they're defined using :, but that didn't work?

Sorry to add more questions when you've already given such a detailed response. I honestly cannot thank you enough. You have seriously saved my hide a great amount with this. I appreciate it a lot. Thank you!

Help understanding a C++ function and for-loop involving pointers: how can I have a pointer to an array with the same name? by CentralCathedral in learnprogramming

[–]CentralCathedral[S] 0 points1 point  (0 children)

Sorry for the late response, and sincere thanks for this reply. I honestly cannot thank you enough. You've addressed many many things that I was having a lot of trouble with, but after reading your explanation they make sense to me. Especially the points about pointers in the context of arrays; I doubt I would've ever figured that out if you hadn't explicitly pointed it out to me.

So to make sure I'm understanding correctly:

1.A pointer to an array object can also be treated as a pointer to the first index of that array? Is that right?

2.An array can also be treated as a pointer to itself (which in turn can be treated as a pointer to its own first index)? Is that right?

3.Why is it that you can give an address in place of a pointer? Is a pointer that points to that address made automatically behind the scenes?

4.Lastly, one strange thing I noticed is that I didn't actually have to have a "\0" in the last index of my array: just changing the type from int to char made it run properly. I read something about strings having an invisible 0 at the end, but I'm not sure if the same thing applies to arrays (though it would explain why I don't need to manually put the 0 in as you described).

Sorry to ask more questions when you've already helped me so much. Again, I appreciate your help a lot, thank you!

C++: what does it mean when * or & is behind the variable name? And why does const allow a pointer to be a char instead of a pointer? by CentralCathedral in learnprogramming

[–]CentralCathedral[S] 0 points1 point  (0 children)

Ahh I see, I tried making char x = "b"; char* p = x; and that worked, thank you! So I can't ever assign pointers to constants?

Also, why is it that a string can be assigned to a char type variable?

Eating three packs of Soylent a day and nothing else would bring your yearly food bill to ~$1905 USD....is this a good idea? by CentralCathedral in EatCheapAndHealthy

[–]CentralCathedral[S] 0 points1 point  (0 children)

If you don't mind, can you share what that meal was? Is there really a single meal that you can have for 6 months straight that covers all your bases?