General C++ Programming - January 2018 (Page 9)

Rules around forward template functions to template functions
 
//g++ 5.4.0 #include <iostream> #include <algorithm> template<typename T> void func(const T& func) { std::cout << func(1, 2); } int main() { func...
[2 replies] Last: Awesome, thanks. Makes sense; the generic lambda is still an instance,... (by elohssa)
Code in the nested do-while loop will not run on visual studio 2017 IDE (windows 8)
 
Hi everybody. Below is part of code for a continuous infrared photon laser travelling scheme. The code is much bigger than this. It is part of the bottom half o...
[2 replies] Last: Hi, Please don't start a new topic about the same subject, just conti... (by TheIdeasMan)
by karl05
Daisy Chains in the Field
 
The usage problem of Daisy chains in the field is extremely hard! Can anyone solve this??!! Problem: Daisy Chains in the Field ========================= ...
[1 reply] : 1. Paint cow 1 green. 2. Let S1 be the set of cows currently painted g... (by helios)
c++ loop speed up
 
I wanted to test how clock function works so i made a simple program but i found something else. #include <stdio.h> #include <iostream> #include <string> ...
[5 replies] Last: Thanks for explanation. I actually didnt wanted to make a program for ... (by anakata)
Adding spaces at null of char array
 
Hey everyone, I have a char array of supposing 20. like char array ; When I enter "Animation is good", it has 17 letters of course. Extra 3 spa...
[8 replies] Last: This could work. There is probably a way to condense it more, but I wa... (by Ganado)
float out of string
 
Hello everyone, How to get float out of const char* eva="I am number 1000.235 abcd" i need to extract 1000.235. Thanks
[9 replies] Last: std::regex num_re( "(?:^|\\s)[+-]?(?:\\d+\\.?\\d*|\\d*\\.?\\d+)(?:\\s... (by Kostantin2)
by yazhai
instantiate the value of "extern const"
 
Hello all, I have a problem with regards instantiating global constant value. I know at most of the time the following code works: In header.h file: #ifndef ...
[8 replies] Last: by definition, a variable is not a constant and a constant is not a va... (by jonnin)
rename class instance member function
 
Hi, i can rename std::next to n, and i want to rename list instance member function.(push_back to put) thanks. std::list<int> a; // a.push_back -> a.put ...
[2 replies] Last: I think it is not practicable, we can not add new method or change met... (by Jun Zhang2)
Functor taking argument
 
I have a customer class containing Name and Age. I am wrapping the customer class in a shared pointer and made a vector of the shared pointer. I have taken 3 c...
[2 replies] Last: Thanks Thomas for the help. (by shekharsahoo)
by Handge
C++ screen keeps flickering
 
I have this code but every time the screen is cleared to redraw the bar it flickers. How would I go about fixing this? clear function (didn't make this) ...
[1 reply] : Clearing the screen on every cycle is asking for flicker. Don't do tha... (by Duthomhas)
by aumars
Is it possible to execute the contents of a switch statement from the bottom-up?
 
switch (i) { case 1: printf("1"); case 2: printf("2"); case 3: printf("3"); } Is there a way to execute the above switch statement such as...
[10 replies] Last: OP is working with an XY problem. (by Duthomhas)
Please Need Help in Assignment As soon As possible
 
Write a program that counts number of prime numbers in an Array. The program must be able to use functions, in particular, The program must use the count as re...
[5 replies] Last: To judge a number n whether is prime, you should test from 2 to floor(... (by Jun Zhang2)
by iffi62
Reading an array from a text file and storing it using Classes and constructors.
 
Hello everyone. I have a an array in a file i-e 1 2 3 4 . each of these numbers are of different attributes. Can anyone tell me the way how to store them using ...
[1 reply] : file.txt: 1 2 3 4 Put each number into the into the Foo class's me... (by Ganado)
std::accumulate inaccurate result for large container
 
Not really a c++ question, but more about floating point precision (I suspect). This gives 1.82 for the average instead of 2. For 5,000,000 it works fine. So ...
[5 replies] Last: Nah in my case I only ever use 1 avx instruction really - no SSE. So d... (by elohssa)
Initialising Array of objects calls constructor twice
 
The constructor for Node has a default value for the parameter it's receiving. When new is used, this default constructor is called. In the loop the constructo...
[5 replies] Last: 2. I'm not sure what you mean. Am I not using an array of pointers no... (by doug4)
String_numput<> facet not writing to string
 
I have written a String_numput<> facet that derives from the num_put<> facet, in order to write to a string. The program is based on an example givenby Stroust...
[5 replies] Last: > In String_numput<C>, a space is not added between successive numeric... (by JLBorges)
Keylogger
 
#include <iostream> // Klavye ile deger girilebilmesi için gerekli kütüphane #include <windows.h> // Programı gizli çalışması için gerekli kütüphan...
[1 reply] : #include <iostream> // Klavye ile deger girilebilmesi için gerekli k... (by olfibits)
copy constructor for a class with an abstract member
 
Hi everyone! This question is related to how implement a copy constructor for a class that has a pointer to an abstract type. Here is an example: class...
[7 replies] Last: void copy(const MyAbstract & other) { const Implement... (by JLBorges)
expected primary-expression before ')' token
 
Hello, Here is some code which generates an error : template <typename T> struct A { template <int i> static void f(void) { } }; template <typename ...
[5 replies] Last: Thank you very much for your answers. The solution of Jun Zhang2 is w... (by frmilstein)
sorting list
 
hello everyone, I have std::vector<string> listItems i want to remove duplicate values not changing the order of the strings eg abc has "B","C","E","D","C"...
[2 replies] Last: #include <iostream> #include <string> #include <vector> #include <set... (by lastchance)
January 2018 Pages: 1... 78910
  Archived months: [dec2017] [feb2018]

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