General C++ Programming - December 2019 (Page 5)

Unit testing in C++ ?
 
Catch2 https://github.com/catchorg/Catch2 with Fakeit (for mocking) https://github.com/eranpeer/FakeIt is very easy to use. Both are single header only librari...
[7 replies] Last: Gotcha. Still, it spawned a thread which actually has some useful con... (by MikeyBoy)
Compiler error: Expected primary expression before...
 
project12.cpp: In function ‘int main()’: project12.cpp:220:23: error: expected primary-expression before ‘int’ displayBoard(int board ) ...
[2 replies] Last: Also, some of your statements are missing semicolons at the end. (by MikeyBoy)
Difficult Bugs
 
Rob and Jason are joined by Satabdi Das. They first discuss a new Visual Studio update and an article written by Bjarne Stroustrup. Then Satabdi talks about deb...
[no replies]
LINKED LIST FUNCTIONS IN HEADER
 
So I want to implement three different functions into my header file. I am working on the first one but I am unsure where to begin. Here is my current header fi...
[18 replies] Last: If you see the time. I edited it at 8:13 and your response came at 8:... (by doug4)
I wonder if I just use like this about template
 
template <class T> class Test { .... Test() {createTest();} using value_type = T; using class_type = Test<T>; using iterator = Test<T>*; .... .... } t...
[8 replies] Last: maybe I should study English.. Don't worry about it. I don't alwa... (by doug4)
by volang
Concat strings, assign to char pointer (1,2)
 
How can do something similar below that works: char * d = new char ; string str1 = "string1"; string str2 = "string2"; d = &str1 + &str2 ; cout <<...
[20 replies] Last: strcpy(a, &str1 ); this is not safe. c++ strings are NOT zero termin... (by jonnin)
by volang
Allocate memory then point it to another block
 
char * a = new char ; a = b; Is the "new char " still associated with "a" somehow? Or is the length of the block that "b" points to now applied to a ?...
[9 replies] Last: A beginner who wants to mix C with C++ before they have a solid under... (by George P)
by volang
Open files without binary set
 
When I open the file(a php file that contains html and javascript) with "ios::binary" the output of the read() is correct. But without "ios::binary" the outp...
[11 replies] Last: This is good. Nice explaining, i get it now. I should use gcount inst... (by volang)
Adding function to header for link list
 
For this function I need it to check to see if the a value in a list is divisible by 5 and 10 and if true then the value gets divided by 5: void NumberList::l...
[4 replies] Last: I see three major mistakes. (1) When you traverse the list you MUST g... (by lastchance)
function, its argument can accept a string variable with and/or without const
 
How do we have a function with its argument accept a variable with and/or without const specifier, without double work or space creating full body size of its o...
[1 reply] : Huh? #include <iostream> using namespace std; void foo ( const int ... (by salem c)
Can I override assert macro? (1,2)
 
I want to add a message in assert like static_assert. It's possible?
[26 replies] Last: The comma is an operator if and only if it is part of an expression ;... (by JLBorges)
a function returning Eigen::VectorXd failed type inference
 
Dear all, I often use Eigen, and when I make a function which returns Eigen::VectorXd and then call it to set a variable type as type inference, "auto", I fail...
[2 replies] Last: Dear kbw Thank you for your kind reply. I understand type deduction ... (by Mitsuru)
by arr
dp with bitsets
 
iam trying to solve a dp problem using maps as follows - #include<bits/stdc++.h> using namespace std; #define M 100000; map< pair<bitset<100000>,int> , ...
[1 reply] : You need to define operator< to compare the map elements. It's unlike... (by dutch)
operator overloading? or overriding? What is the right?
 
I know the difference between overloading and overriding. overloading is doing add function another version with the same name. and overriding is to change ...
[2 replies] Last: Thanks for your answer! (by woohyeon)
by fog22
What does this error code mean? exit code -1073741819 (0xC0000005)
 
I am trying to recursively sort by job title. Job Title is declared in the Employee class. Whenever I attempt to recursively sort the stack , the popping is ...
[3 replies] Last: Check for null before using a pointer. Top is null in this case.... (by kbw)
can you help me for Data Structures
 
Hello guys I can't do this can you help me please. In computer science, an arithmetic expression can be written as either a postfix, infix or prefix express...
[1 reply] : If you google "infix to prefix" you'll find some solutions. (by dhayden)
Can you check me if this is valid program ? because i dont find an output screen
 
//Example: Write a program that reads grades from a file and store them in 2x4 array. Then it finds and displays the max min of each row. PS: file is opened ...
[1 reply] : add a cin statement the end of it, see if that helps. if so, you are ... (by jonnin)
by b p t
Open mailbox
 
Hi I need some code wich will open mailbox like "mailto" in html. Thanks
[2 replies] Last: It worked. Thank you (by b p t)
Allocate a length of new C++ string dynamically
 
How to create/allocate a length of new C++ string variable in in runtime ,ie. dynamically
[6 replies] Last: you can also just take &var If you need a non-const char* you can j... (by Peter87)
by volang
Read in more than memory allocated
 
Good day everyone! char * l = new char ; //Creating pointer to a block of memory, length 4. int length = 20; file_content.read(l, length); //telling the fun...
[10 replies] Last: Great! Thanks alot, it's appreciated (by volang)
December 2019 Pages: 1... 34567... 10
  Archived months: [nov2019] [jan2020]

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