General C++ Programming - May 2020 (Page 4)

When should I pass by reference?
 
So I know passing something by reference can save time since you don't copy something, but should I pass by reference in this situation: // I know this is...
[4 replies] Last: Furry Guy, if all you do inside the function is to read owned object y... (by malibor)
Compile time decision whether a pointer type is NULL or no
 
How do we check at compile time whether or not a pointer type argument is nullptr in C++?
[2 replies] Last: You can use the standard type trait std::is_null_pointer: https://en.c... (by TheToaster)
Increment and Decrement Operator Overloding
 
Hi, i have my submission in 8 hours and the code is almost complete. I asked one of my fellow friends they said that there is an issue with increment and i don...
[1 reply] : Your increment and decrement ops are supposed to modify the 'this' obj... (by dutch)
Codelite Debugger Issue
 
Hi, I'm currently using Codelite on a mac. When I try to use the debugger, I get an error saying "Failed to locate gdb! at 'gdb'" When I go into the build sett...
[2 replies] Last: there's Settings -> GDB setting -> Debugger Path in image: https://m... (by marhuum)
How can I configure CGAL with CMake?
 
Dear All, I hope you are all well and healthy. Currently I am working on the installation of CGAL for my 3D project. I installed CGAL using the vcpkg p...
[2 replies] Last: Sorry, your OS is Windows, some installation procedure differs from Li... (by Mitsuru)
C ++ homework help
 
Find the product of two matrices, a (3x3) and b (3x3), where the user enters the values, and find the determinant of the c matrix to be obtained and write the...
[9 replies] Last: I don't know what you're apologizing for, we're just saying to be more... (by Ganado)
by Vycues
I haven't used C++ Templates and I am getting multiple syntax errors (1,2)
 
I am using C++ Visual Studio Community 2015. I am using the template with a class that has a std::array. I tried moving the function definitions after main, but...
[30 replies] Last: I see. I fixed the fill function as you suggested and it works. Thanks... (by Vycues)
by frek
Rule of Zero
 
Hi folks, I've read much about rules (zero, three and five) on the Web, and tried well enough, but understood none of them "completely". Each rule has some a...
[7 replies] Last: IMHO, the 0/3/5/6/? is just one, unambiguous rule: Do what you have to... (by jonnin)
contructor vs inline initialization
 
what is the difference between template<class T> stuct S { T x = value; }; and template<class T> stuct S { T x{ value }; }; and template<class...
[2 replies] Last: as Core Guidelines put it, C.48: Prefer in-class initializers to membe... (by Cubbi)
C++ coding quiz
 
There're 4 bytes in a row, each is to be its own value How do we find the byte of greatest value out of them by the simplest, elegant C++ instructions.. which ...
[1 reply] : https://www.cplusplus.com/reference/algorithm/max_element/ (by salem c)
Why do we need dynamic memory allocation in C++?
 
Hello, Greetings; hope you all are fine, safe and doing well. I am doing my BSSE through course material it does not make any sense to me Why do we need dynami...
[6 replies] Last: Another point to consider: data* return_data() { data d; ret... (by TheToaster)
cppdb link errors
 
I have been trying to use cppdb (http://cppcms.com/sql/cppdb/index.html), but I can't get past linking. As an experiment, I tried compiling and running the samp...
[4 replies] Last: Glad you got it working. In general, there's really no guarantee that ... (by Ganado)
Range based for loop
 
I am a bit stuck on this question #include <iostream> #include <vector> using namespace std; int main() { vector<vector<int> > magic_square ={{1, 14, 4,...
[5 replies] Last: When using range based for loops, you are working with the actual valu... (by doug4)
&& not working as expected
 
For my assignment I have to take sets of 3 integers separated by spaces from the user input and determine whether or not they can form a triangle, and if so w...
[1 reply] : However the loop is exiting if only one condition is met. Thats wh... (by TheToaster)
std::allocator implementation
 
does anyone know how the default STL allocator class works, I need help implementing this template<typename T> class allocator { public: ...
[3 replies] Last: forgot Microsoft's: https://github.com/microsoft/STL/blob/master/stl/i... (by Cubbi)
decltype
 
I have this question but I don't think I fully understood how to use decltype map<int, float> m = build_map(); std::pair<int, int> scaling_factor(2, 3); std::...
[2 replies] Last: Maybe this? using type = decltype(std::pair<int, int>()); using ft... (by malibor)
std::experimental::future
 
Could someone explain to me the operation of std::experimental::future? I read about it in C++ Concurrency in Action, 2e but the author's example doesn't really...
[7 replies] Last: Well, in the particular case of futures/promises, there's the implemen... (by helios)
How do I get my won/loss/tie counter to work?
 
#include <cstdlib> #include <ctime> #include <iostream> #include <string> using namespace std; int main(void) { bool looping = true; while (l...
[2 replies] Last: Thank you (by Programmingaddict)
by RicoJ
Wrong std::reference_wrapper to reference assignment?
 
I was expecting to get -4, but I ended up getting -3. I thought ret in foo will keep a reference to l.front(). Why did that happen? struct S { int v...
[11 replies] Last: That's what I get for not reading things properly. I would still not a... (by helios)
One more line of code I need to make it work
 
My program inputs two integers and determines if the first number is a multiple of the second number. I want my program to output three things: If the first ...
[3 replies] Last: I think your original code is preferable. 4 is not a multiple of 0, so... (by dhayden)
May 2020 Pages: 123456... 9
  Archived months: [apr2020] [jun2020]

This is an archived page. To post a new message, go to the current page.