Beginners - August 2022

Linked list of structures
 
Hello! in C we define node : struct Node { int data; struct Node* next; }; Does next pointer is pointing to the data of the next node? If i...
[9 replies] Last: it is not mean that next pointer also point to the data? C++ allows ... (by mbozzi)
Floating-point comparison for mortals
 
I see a menacing dark cloud looming on the horizon and I wonder why other beginners aren't as concerned as I am. Have they ever had to deal with floating poin...
[9 replies] Last: #include <iostream> #include <limits> #include <iomanip> #include <cm... (by JLBorges)
Problem with delete function.
 
So our prof tasked us to delete a block of array. Technically in this case, to delete GroceryList_fin or the first block in the GroceryList_fin array. Our ...
[7 replies] Last: Your assignment operator doesn't assign . You probably should remove... (by kbw)
by Geckoo
override specifier
 
Hello. In the next code, must be written the keyword override in the derived classes or not? It seems to me that the virtual keyword in the base Class is en...
[8 replies] Last: Re. virtual destructor When a base class is intended for polymorphic ... (by JLBorges)
I have a lot of problems.
 
So basically, our professor told us to do: Problem 1: Create a class for the fruits and the vegetables. Each class must have a constructor, deconstructor, copy...
[8 replies] Last: "Create a class of vegetables ..." It's been a long day: I just misre... (by lastchance)
Why is this not working?
 
I don't know why my code doesn't work and my reference code works. I am trying to copy this code by making my own code which is now directly similar to t...
[6 replies] Last: Don't use string.h for the include - it's string. Hey! Did not see t... (by Geckoo)
by colt
Destructor causes memory exception
 
Hello. In the program I am creating, I created a destructor in a certain class, one that calls delete to remove two dynamic allocated array from two different u...
[12 replies] Last: An important question is whether you have "legacy" code that does not... (by seeplus)
static inside a class, inside a method
 
If I call a method in a class a million times but I don't want it to create and delete the variable a million times, what to do? Can I add static to it and it w...
[19 replies] Last: At the end pop off the function and the static still stays on. But w... (by Peter87)
copy constructor and initialization (1,2)
 
Greetings! I don't understand why the copy constructor does not work for initializing an object with a return value of a function. Example, a class "person": ...
[29 replies] Last: An issue with copy assignment is that you'll probably also then need a... (by seeplus)
Need a help slicing 2D vector
 
Hello everyone, I need a help slicing a 2D vector. I guess it is easy but since I am complete beginner I could nout achieve to sclice them. I have one 1D vecto...
[4 replies] Last: std::slice doesn't work on a vector, only on a valarray: https://en.cp... (by George P)
' ' is not a member of 'std'
 
I don't know how to fix this error error : 'answer' is not a member of 'std' #include <iostream> #include <vector> #include <string> class Triangle{ pr...
[14 replies] Last: Monument Valley is ethereal - quiet delivering good vibes. One of its ... (by Geckoo)
by Geckoo
Another Guess My World
 
Hello. I continue to increase my understanding of the OOP principle using C++. I made another game - Guess My Word. Not a big revolution - just another exercise...
[14 replies] Last: But it seems to me that I did that before... True, but if your progra... (by kbw)
by NowIC
VS Code and multiple files (libraries)
 
Hello. I setup VS Code to work with gcc and gdb (Windows 11 with mingw64). The compile and debug with 1 file works fine. Now, how do I setup the tasks.json and ...
[no replies]
How to update Eigen matrices correctly in a solver?
 
I have an iterative solver where it solves a PDE by given an initial guess and updating it until a convergence criteria is met. My question is embarrassingly si...
[14 replies] Last: @TheIdeasMan I discovered what a PDE is Partial Differential Equation... (by JamieAl)
Current Usage of Copy and Move Constructors
 
I was following a course from Udemy. But I lost my interest in the c++ language 3 months ago because of these copy and move constructors. As far as I know, they...
[5 replies] Last: It's hard for me to learn them and probably because of the instructor... (by George P)
How to return multiple data from a function
 
Hello fellows, In a function , I do some mathematical and obtain a vector , a double value and one 2D matrix. I need to use all these three outputs later in a...
[7 replies] Last: #include <vector> #include <tuple> using Array = std::vector<int>; u... (by keskiverto)
Possible reasons for the loop that does not call a function more than once
 
Hello fellows, When I call the Func1 in the loop in Func2, it does not call the fucntion more than once, ie; the loop does not iterate. In Func2, in Func1 , w...
[5 replies] Last: Thank you so much for all these replies. @zapshe, thank you so much. Y... (by learner999)
Bracket problems
 
I think there's a problem with my Bracket alignments or is there any problem in my if -else statement positions? #include <iostream> #include <cmath> #includ...
[3 replies] Last: Thank you guys you solved my problem!!! very much appreciated :) (by cplus2303)
Cyclic dependencies and forward declaration
 
Hi guys, I have a question to the following. Imagine two classes A and B that use one another. The naive approach: have the respective header files include ...
[10 replies] Last: This, and a lot of other design issues, are discussed in this great bo... (by seeplus)
by Wedde
Handle cos, sin function.
 
I dont believe i get the correct results. Is something wrong with the way i use the cos and sin function? When the angle i 45 degree the x y velocity should be ...
[5 replies] Last: #include <iostream> #include <vector> #include <cmath> //double posi... (by lastchance)
August 2022 Pages: 123
  Archived months: [jul2022] [sep2022]

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