General C++ Programming (Page 3)

data struct selection
Which data structure is more ideal here? 1)Frequently need to add and remove elements from the middle of a list, and you will not read it very frequently? I tri...
[10 replies] Last: Thanks everyone for your inputs. This thread can be closed. (by leo2008)
does vector <int> myVec [5] creates 5 vector?
and list<int> myList creates 10 linked list? the and () seems to be very different.
[6 replies] Last: std::vector<int> myVec creates a C-style array with 5 elements, eac... (by George P)
How does vector initialize and allocate in one line?
How, as vector<int> n(9) is allocating, can vector initialize and allocate in one line (as giving error in this e.g.) ? #include <vector> using namespace std;...
[3 replies] Last: Note that the number that you pass to the constructor (inside the pare... (by Peter87)
Linker 2019 error unresolved external symbol
I am pretty sure I have something wrong with how I am using my templates like syntax. I am making a program that works with an array-based Queue. I might have h...
[8 replies] Last: Including a .cpp into my header (I know I should not do this now) I t... (by Ganado)
by Cplusc
how initialize an object of a class which is defined within a name space
I am trying to initialize the ex and ey variables in the following piece of code but unfortunately I keep getting linker error. thanks in advance. namespace L...
[10 replies] Last: Well, strictly you could use MPI_Allreduce, but I take your point. (by lastchance)
Object oriented programming menu troubles
Hello all, i am in a programming 2 class and thought i was understanding quite well, but i am getting stuck with this project my professor assigned. I believe i...
[6 replies] Last: If you post a file data sample, we can provide advice as to how best r... (by seeplus)
How to print Eigen tensor EVERY iteration?
I made an older post about printing an Eigen tensor into a text file and where the example I am using here isn't really ideal, it ended up working for me throug...
[5 replies] Last: @mbozzi Thanks A LOT! This is perfect. (by JamieAl)
File stream read in error
Hello! Context: I am making a simple code to read in a maze from a file the maze should look like this: 5 5 .S.#. ##.#. ..... .#### ....F but instead, it lo...
[2 replies] Last: Thank you and also I added the code tags ty for the article (by kailarob)
how to prevent duplicate when compare 2 string vector.
#include <iostream> #include <vector> #include <random> #include <algorithm> #include <iterator> #include <ctime> #include <set> using namespace s...
[5 replies] Last: It has been a while since I have used c++. The forum format has change... (by oggin)
by Cplusc
elseif condition in macro
anyone knows why I am not getting the _dim and _nnodeLtc correctly from the following piece of code? #pragma once #ifndef _INCLUDES_H_ #define _INCLUDES_H_ #...
[13 replies] Last: thanks for your answers. (by Cplusc)
how to print Eigen tensor to text file?
I am trying to print a 3D matrix into a text file and use it to make plots in MATLAB. I have been using std::ofstream("3DTest.txt") << Test; for all my Eigen ...
[6 replies] Last: The issue is this is readable as 16x256 instead of 16x16x16. Same ... (by lastchance)
sort option needed
which sort (bubble,quick, merge) option best suited here? 1)A list sorted except for one item, which is in wrong place? recursive merge sort??
[12 replies] Last: Better to use the C++ library for most uses of sorting instead of rel... (by keskiverto)
Error when taking max value of Eigen tensor
I am trying to get the max value of an Eigen tensor, something equivalent to max(max(max(T))) in MATLAB. The thing is I got a case that works for me: stat...
[4 replies] Last: @lastchance Thanks! I am confusing myself A LOT because I am using MA... (by JamieAl)
How to do dynamic scoping
How come not able doing a dynamic scoped variable, how to do dynamic scoping in c++ as this illustration fails: void f(int i); void fn(int& m){ int i; ...
[6 replies] Last: Respectfully @abdulbadii I don't understand why you don't want to use ... (by Geckoo)
inline assembly
hello all , i make hook to read some address from ebx to this value all work good But every time the same address is printed, I'm sure there are many address...
[no replies]
Output inside function mismatches outside function
Why does my function returns zeros when called in a script but then if I try to print out the output "inside" the function I get the correct results? I am confu...
[2 replies] Last: @JLBorges oh I see. Thanks! (by JamieAl)
One explain on initializing each vector argument.. please
one outright understand definitely each vector argument in initialization (v) ? enum Mon : int { A = 5, B, C }; struct M { explicit M(Mon m, M...
[2 replies] Last: When posting code, please use code tags so that the code is readable ... (by seeplus)
by t im
Virtual function and class inhertance
I'm confused about the code below: class A { public: A() { bar(); }; virtual ~A() { bar(); }; virtual void foo() { cout << "1"; return; } virtual vo...
[4 replies] Last: Truly grateful for all your help. I get it. (by t im)
by t im
About std::move string and int
string s1 = "str"; string s2 = move(s1); // s1 is empty int num1 = 1; int num2 = move(num1); // num1 is still1 Just as the code above, why does the st...
[5 replies] Last: Thanks for all your relpy. I get it. (by t im)
by t im
Const with function
What is the difference between 'const' before and after function name in the code below: const int foo() // const before { return 1; } int main() ...
[5 replies] Last: I guess I must have misread the question because I ended up answering... (by Peter87)
Pages: 1234
  Archived months: [sep2022]

Cannot post in this page. To post a new message, go to the first page.