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"); }...
Nov 13, 2021 at 12:04pm
[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...
Nov 12, 2021 at 2:11pm
[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...
Nov 12, 2021 at 1:03pm
[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>...
Nov 12, 2021 at 9:39am
[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(...
Nov 12, 2021 at 9:12am
[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...
Nov 11, 2021 at 6:03pm
[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. ...
Nov 11, 2021 at 2:24pm
[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...
Nov 11, 2021 at 1:58pm
[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 ...
Nov 11, 2021 at 10:11am
[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...
Nov 11, 2021 at 9:37am
[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 ...
Nov 11, 2021 at 3:52am
[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...
Nov 10, 2021 at 10:45pm
[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...
Nov 10, 2021 at 8:06pm
[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...
Nov 10, 2021 at 5:18pm
[3 replies] Last: Perfect. (by Duthomhas)
1
123
Nov 10, 2021 at 12:17pm
[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(...
Nov 10, 2021 at 2:17am
[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); //...
Nov 10, 2021 at 2:16am
[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.
Nov 9, 2021 at 5:58pm
[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...
Nov 9, 2021 at 4:25pm
[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...
Nov 9, 2021 at 3:53pm
[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.
Registered users can post in this forum.