General C++ Programming - October 2020 (Page 2)

Array typecast operator overloading.
 
Say I have the following (incomplete) class. class IntArrayWrapper { private: std::array<int, 3> array; }; Is it possible to overload the implicit typeca...
[4 replies] Last: Do you mean something like this? #include <iostream> #include <array... (by dutch)
Validating user input twice
 
Hey ya'll I'm working with classes and need some help with validating user input from the main. I'm supposed to set and verify 5 array object with data entered ...
[2 replies] Last: One of the points in having setters is that they do any required valid... (by seeplus)
array and iterators
 
#include <array> #include <random> #define MAX_TILES 100 class TILE; // Forward (polymorphic) class BAG { public: typedef std::array<TILE *, MAX_TILES>...
[12 replies] Last: @thomas1965 & coder777, Thanks. I didn't think about iterator arith... (by AbstractionAnon)
Encrypting A File Into An Output File
 
I an a beginner, and I need to make a C++ program that will go through the first step of encrypting an input file and writing the encrypted contents to an outpu...
[3 replies] Last: you can do it in about 10-15 lines... read file stuff <random> -- seed... (by jonnin)
Number of Primes in Range (1,2)
 
Write a program that asks the user for two non-negative integers and then displays a message indicating the number of primes found between the two numbers enter...
[25 replies] Last: I think gcc is closer to the actual compiler. You can use any of g++, ... (by lastchance)
constructors and assignment operators
 
Could someone check if the constructors and assignment operators are in a right manner? #include <iostream> #include <stdexcept> using std::cout; template<t...
[2 replies] Last: X& operator=(X&& other) { cout << "move assignment\n"; data = ot... (by seeplus)
by thmm
Generating make files
 
How would you create a makefile for a project that has only a bunch of .c and .h files? Are there any tools available that can create makefiles?
[5 replies] Last: I don't know anybody who likes to set up Makefiles. If you find a too... (by doug4)
Iterative Loops And Small Problems #1-3 (1,2,3)
 
PROBLEM #1 Bob & Patrick’s Seashell Emporium uses mailing labels for shipping boxes. Write a program to display a mailing label for each box to be shipped...
[44 replies] Last: If you look back at the original assignment in the first post, there w... (by doug4)
Simple charade game
 
Hello! I was thinking of making a charades game. Just a simple one wherein when you run the code it will display a Category and then the Word that the user will...
[no replies]
by mnm71
How to access function that use another class?
 
I use a class in another class like this : a.hpp Class A { public: void foo(); }; a.cpp #include "a.hpp" void A::foo() {} b.hpp #include "a...
[8 replies] Last: @keskiverto thank you my problem resolve with your solution And than... (by mnm71)
Ground symbol (code by Charles Petzold)
 
Hi guys, currently reading code by Charles Petzold, on chapter 5, he mentions words such as common and ground but I can't figure out what they do and how ...
[7 replies] Last: When you find a common part of a circuit, you can remove the wires an... (by mbozzi)
by mnm71
How use JSON template in string ?
 
I want to send {state:success,value:i} // i is a float, take values from some function like the JSON template format over TCP server socket, if I don't u...
[2 replies] Last: @helios thank you for replying to my question (by mnm71)
Where to ask C# questions?
 
Hello. I am trying to learn C# and I have some questions. Does anyone know where I can ask these? Website, etc. For anyone who can help here, I'm having ...
[6 replies] Last: Thanks for answering. :D (by SirEnder125)
Swapping array elements using pointer addressing
 
Hi, I have created a 1d array of 25 elements that I'd like to manipulate using pointers. So far I have the array printing out as if it were a 2d array. I wou...
[3 replies] Last: I ended up using two constant variables, one to let the for loop know ... (by oceanSpray)
by alexas
random generator in the constructor
 
Hello, I want to use the random generator which initializes every time when constructor is called: StructureGenerator::StructureGenerator(const float& mo...
[19 replies] Last: To sump up, after learning about more about the topic, it seems that m... (by alexas)
by lambam
Stuck on Office Project
 
A business needs to calculate the bonus points for sales representatives. The bonus points are based on how much each sales representative sold the year. Wri...
[7 replies] Last: 1. Don't put semi-colons after your if statement. 2. ((salesamounts >... (by Ganado)
Why const reference string
 
Hi everyone, I just wrote this piece of code to test something, but it didn't go through the GCC-compiler because of the following error: C:\Project\TESTS\QtCr...
[4 replies] Last: The const reference is special. The compiler is free to generate a tem... (by coder777)
C++ - incrementing integer variable does not work
 
So I'm creating a program that implements several classes representing a school, and its students and courses. I'm running into an issue in School.cc where the ...
[1 reply] : Also posted here http://www.cplusplus.com/forum/beginner/273440/ (by seeplus)
How to clear console without system("cls") (1,2)
 
Hello. I have been told that system() is "bad" to use... So, how do I clear the console screen safely without system()??? I doubt there is a way that anybody ...
[26 replies] Last: See my previous post. VT100 code support was introduced into Windows 1... (by seeplus)
How do I modify my code to organize objects and write them to a file.
 
Ok... i'm stuck here... I have a class called Items that creates an object with three attributes (MeshNumber, MaterialNumber, and name). I then have another cla...
[5 replies] Last: Simply, the spec for operator<< (and operator>>) requires the stream t... (by seeplus)
October 2020 Pages: 12345
  Archived months: [sep2020] [nov2020]

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