General C++ Programming - November 2021 (Page 4)

May memory leak in vector<>?
 
I am confused about the memory mechanism in cpp, here is a example. { vector<A> a = {A("object1"), A("object2")}; a .print(); a = A("object3"); }...
[2 replies] Last: You should consider logging the copy/move constructor/operators. You'... (by kbw)
by Cplusc
macros
 
Hello everyone. I am writing a finite element code and I want my code works for both 2d and 3d applications. I am writing the code using OOP method and I have s...
[7 replies] Last: Thank you all for your answers (by Cplusc)
Compiler errors in C++ code
 
Hi All Any idea what is wrong in the below code ? #include <iostream> using namespace std; class SomeClass{ protected: int data; f...
[3 replies] Last: Here main() is not allowed to access the protected member data of Som... (by doug4)
Help in Recursion
 
I'm having difficulties in understanding the logic regarding the recursion? Can someone help me explain how do I get an output of 7 in it? #include <iostream>...
[1 reply] : It actually adds the digits. In this example 0 + 0 + 5 + 2 = 7 This ... (by coder777)
How to use members of class
 
So I have a program written using structs now I want to which it over to a class contacts .duration = contacts .end - contacts .start if(infile.is_open(...
[13 replies] Last: holy ***** this dude/duddete just saved me I had no idea that float co... (by UeleseA)
c++ output choice
 
I recently took c++ multiple choice test and below questions are always confusing me. Any inputs? Question1: which of lines of code substituted for occurenc...
[12 replies] Last: Q3 has usable snippets. just remove the 1) type markers... removing t... (by jonnin)
Compiler optimization question
 
Can anyone help me explain why one a compiler might perform the following optimization. Assuming all variables are declared and initialized appropriately. ...
[7 replies] Last: it varies. My complaint is most docs throw the house on you. me: I... (by jonnin)
Recursive Problem Help
 
Hello guys, I just need some help with the code below. I just need to fix it by successfully printing the expected output below. My output: 123456789101112 Ex...
[4 replies] Last: Thanks. I appreciate that. (by ForgottenLaw)
Virtual memory paging page replacement?
 
With regard to virtual memory paging page replacement, can anyone explain to me why referenced but not 'modified' pages might be replaced before referenced and ...
[2 replies] Last: There's also the concept of LRU (least recently used) when deciding wh... (by seeplus)
C++ Code issue
 
Hi All I am stuck with the below C++ Compiler errors. Any suggestions? #include <iostream> using namespace std; class XXX{ public: int...
[9 replies] Last: Add the line virtual ~XXX() = default; in the class XXX declaration.... (by lastchance)
lvalue rvalue returns.
 
Cam I write a member method called Dereference which will do both these s.Dereference() -> prints the value of the variable. s.Dereference()=4.9 -> sets ...
[3 replies] Last: Thank you... (by vidhya5)
Puzzled by Debug Assertion
 
I'm getting Debug Assertion Failed [File and line equivalent to snippet line 36] Expression: Vector erase iterator outside range This snippet is no...
[9 replies] Last: Found it. In several places i intentionally pass RACK by value, which... (by AbstractionAnon)
What would be an appropriate application for static partitioning?
 
I know that static partitioning is used for Predetermined, fixed sized, unchanging memory blocks, process(es) start initially and stay in the system, that new p...
[1 reply] : What is your answer and reasoning? (by AbstractionAnon)
Scheduling systems: batch vs preemptive
 
I'm having trouble understanding the thorough differences between the two, but I know it is in the following: For Batch: -Processes are preempted in order t...
[3 replies] Last: Perfect. (by Duthomhas)
1
 
123
[2 replies] Last: When you post code, please use code tags and sensible indentation. See... (by keskiverto)
What does this program do? Can someone kindly shed some light on this for me please.
 
#include <iostream> #include <iomanip> #include <random> #include <array> #include <ctime> using namespace std; unsigned int rollDice(...
[no replies]
What does this program do? Can someone kindly shed some light on this for me please.
 
#include <iostream> #include <array> using namespace std; const size_t arraySize{10}; int whatIsThis(const array<int, arraySize>&, size_t); //...
[no replies]
template class with .inl logic
 
How can I create and implement a template class with *.inl implementation in c++ using vs 2019? I also need the steps to compile it as well.
[5 replies] Last: Ok understood, thanks to clarify. (by denver2020)
Scripting language for level creation
 
I'm an OpenGL C++ programmer writing astronomy-physics simulators such as Kerbal. My website is photonbytes.com I'm completely unfamiliar with commercialscri...
[6 replies] Last: Lua is good but do you need it? It may be like using a flamethrower to... (by jonnin)
by jreef
Help with nan issue
 
I'm smoothing position data read in from an external source then executing a finite difference to get velocity... I am also smoothing both results. The smoothin...
[10 replies] Last: I suspect you're loop is running multiple times in the same millisecon... (by dhayden)
November 2021 Pages: 123456
  Archived months: [oct2021] [dec2021]

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