General C++ Programming - July 2017

by nsi
A Very Strange Phenomenon
 
Dear C++ programmers! I am experiencing a very strange phenomenon. I am coding up a CFD code solving a totally hyperbolic problem. Governing Equation is comp...
[2 replies] Last: they are completely the same No they aren't. 5.0 / 9.0*rhov_1*gd_1... (by dhayden)
by mmgh
std::find_if on slave nodes
 
Hello, I am broadcasting a vector of object whose members are all std::string from the master node to slave nodes. The sending and receiving seem to work pro...
[1 reply] : It's impossible to tell what the bug is without seeing the code. Pleas... (by dhayden)
by ztdep
why the C++ Mathematical Expression Library compiled so slow
 
Dear friends: I downloaded the C++ Mathematical Expression Library from the web, and i uploaded it in the attachment. It consists of only one head file. B...
[2 replies] Last: Since it is only 1 header file using pre-compiled header files would b... (by Thomas1965)
Virtual Functions Question
 
Hello, I have a question regarding virtual functions. class Base { public: virtual void sound() { cout << "Bass" << endl; } }; class Derived : public ...
[7 replies] Last: You only use polymorphism with Object Oriented Programming, never with... (by kbw)
by nyck66
C: seg fault when filling array inside struct
 
I have: typedef struct { int* data; unsigned int len; } intarr_t; I do: intarr_t* ia=malloc(sizeof(intarr_t); ia->len =5; int val=1; for(int i=0; i<...
[2 replies] Last: As stated, need to assign a value to ia->data. intarr_t* ia = ma... (by Chervil)
by nyck66
C: Asteroids shot and asteroid collision detection
 
I realize my code is C but the section I have questions about is the same as C++ (I think). I am having problems registering a hit when a shot is at point (1,...
[5 replies] Last: @lastchance thanks, it worked when I only modified shot and not roid. ... (by nyck66)
reference can't be bind to different object
 
As far as I know, reference can't be bind to different object But, why the reference c in code below can be bind to different object? string s("Hello world...
[3 replies] Last: You don’t need to blindly trust me, of course :-) If you read here ... (by Enoizat)
Understanding an exercise
 
Hi, I'm trying to solve the exercise of chapter 20 of the book: Programming Principles And Practice Using C++2nd Edition May 2014. Here is the image of some ...
[1 reply] : > Does it mean that we should define some characters as separators for... (by JLBorges)
StringStream >> char not working?
 
We recently covered function pointers and I had an epiphany - that an array of them can be used as an operator stack. This program takes in a string containing...
[3 replies] Last: Something like this perhaps: char next ; while( ss >> next ) { // ext... (by JLBorges)
Erase one element in vector in 'for' cycle
 
Below are some code which use erase in 'for' cycle. It want to remove a element which meet the condition. typedef std::vector<struct pollfd> PollFdList...
[3 replies] Last: > I think it is OK? Yes. This would be the idiomatic way of doing t... (by JLBorges)
Array - for storing the first value
 
I have written a C++ code for my project. I am having trouble storing values in arrays. I have written a code for measuring the value from hardware. For storing...
[3 replies] Last: It sounds like you need to share data between methods of the Motion cl... (by dhayden)
accessing members of class
 
Hi - I'm writing some code for a filter for a DSP application. The user needs to access the members (real and imag) individually for the purpose of something...
[1 reply] : declare it as protected, the the derivative class can use it. (by ztdep)
Program to correct unwanted space and capitalization; but I don't want it to delete the first word
 
// Trying to run on Visual Studio // EXAMPLE: THIS is a space TODAY. // SHOULD BE: This is a space today. // and end it with: Thank you for your time NEVER ...
[no replies]
Unordered map and files
 
I need to let user fill unordered map, write this map in file and then read and use this info from file
[1 reply] : Here is a way you could break the problem down into manageable pieces.... (by dhayden)
Need Help in circuit diagram of 8*8 reed switch matrix
 
I am designing 8*8 reed switch matrix which will be connected to Arduino. I am using Arduino Duemilanove. I have completed the matrix portion but don't know how...
[1 reply] : You can use the internal pullups of the arduino if you're willing to a... (by Jerrydgevdev)
PPP2 Chapter 15 Exercise 6 (1,2)
 
Exercise specification: Design and implement a bar graph class. Its basic data is a vector<double> holding N values, and each value should be represented b...
[29 replies] Last: How do I get the bars to appear inside the 600x400 area of the window,... (by DragonOsman)
by Handge
How to make game save code
 
Hey, I was just wondering how would you make a game save code. Something like a long set of numbers or something like 7182737124 which each number means one thi...
[12 replies] Last: Well thanks all! Thanks, Handge (by Handge)
Question about notation
 
I know what %c is if c is a character, but can someone explain me what c%7 == 0 means? Thanks
[6 replies] Last: Thank you very much guys! (by aurimas13)
Logic Error with Paper/Rock/Scissor Game
 
Hi, I am writing a program with Paper/Rock/Scissor game, and the rule of the game is: - when Paper battles Rock, the strength is doubled - when Paper battles ...
[2 replies] Last: Thank you for your advice, I am planning to rewrite the code. (by condgraduate)
by RezaAb
Eigen functions crash in the 2nd round of a for loop
 
Eigen functions crash in the 2nd round of a for loop I am using some Eigen functions in my code which has a for loop. I have no problem in the first step but ...
[no replies]
July 2017 Pages: 123... 6
  Archived months: [jun2017] [aug2017]

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