Beginners - May 2020 (Page 12)

Quick help with ifstream (reading data from file)
 
Hey guys, I have .txt with data in it : 2 3 0 128 0 255 0 0 255 255 255 255 255 0 255 0 0 255 255 0 First two numbers (2 and 3) are used for outputting the re...
[2 replies] Last: If your RGB data is encoded as 3 numbers to each line I'd probably cre... (by deleted account xyzzy)
Pass class method to object
 
Can I somehow pass class method to aggregated object? I want to run one method inside Hero object too aswell. class Menu { public: Menu();...
[5 replies] Last: i've got displaySomeText() const; which i want to use in two differen... (by dhayden)
Filling a cstring array with text from a text file
 
Hello all, I wanted to try out the cstrings and decided to use them with File I/O in c++. I want to fill a c-string array with text and then print out how many ...
[12 replies] Last: #include <fstream> #include <iostream> using namespace std; int mai... (by againtry)
Removing an element from an array
 
I have .txt with this data : 5 Z 14 R 12 G 20 R 5 R 6 my goal is to add same letters into one total sum, while removing the used colors. So I should get : 3 ...
[1 reply] : Use a std::map to accumulate similar values. (by lastchance)
Help with switch-case statements
 
Hello, I'm working on this problem for my C++ class. The question is to write a program that does the following: Prompts a user to enter Y or y to begin the ...
[8 replies] Last: @Handy Andy, you are right. It was in a previous post and I missed it. (by Thomas1965)
by Nitsou
I get the error : [Error] expected primary-expression before 'int' for line 17
 
#include <iostream> using namespace std; int subtract(int a, int b){ return a-b; } int main(){ int x,y = 0; int & z = x; int & v = y; cout<< "...
[2 replies] Last: hahaha my bad! (by Nitsou)
by vysero
Undefined reference
 
I am getting an error when I try to use the method in this header file: undefined reference to 'SuiteVersions::bProductionBuild()' I included the header...
[3 replies] Last: @dutch Yes that's exactly what it was. I needed to include the lib in ... (by vysero)
Returning To A Menu
 
Hi, so I have a program which adds objects to a Linked List after selecting an option from a menu. Looks a little like this: Menu::myMenu(){ //MENU OPTIO...
[4 replies] Last: Can you at least give more detail about Menu? What do you mean by "ano... (by dutch)
Text file and string array
 
I have a text file which actually is a book and I have to store 1000 random words to a string array. I was thinking to store first all the words of the text int...
[4 replies] Last: @dhayden, for step 2, "select 1000 numbers from 1 to N", you want that... (by dutch)
Bool remove from array by value
 
Was recently tasked with removing all instances of a value from an array with a boolean function. I have it working but was wondering if there was any way to wr...
[3 replies] Last: Yes, it can be improved. Instead of copying the entire remaining array... (by dhayden)
Forward declarations of classes, invalid use
 
Hello, I was given an assignment to write a program which demonstrates the usage of classes. #include <cstddef> ///NULL class BRANCH_CLASS; class F...
[2 replies] Last: Thank you very much! It worked. (by arczi w)
by hbcpp
Iterating a file
 
I have a school assignment where I have to work with memory allocation. I have to iterate a file and get the content of the file into an object. Something lik...
[4 replies] Last: Actually, apparently as of C++11, you don't need the file.clear() fir... (by hbcpp)
Create smart calculator.
 
Hello, I need to create smart calculator. For example, i need to find Sum of 7 and "three", compiler must write: 10. Or "two" plus "two" are equal to 4; I ...
[5 replies] Last: double a = get_number(); double b = get_number(); char operation ... (by lastchance)
by defs
polymorphism
 
Hi, this this a part of my code, so i have a problem with "virtual double Add()=0;" function, if i delete it my code works but i need it another class, so how i...
[4 replies] Last: When you want to instantiate an object of a derived class from an abst... (by nuderobmonkey)
How to use a loop to fill an array
 
My prompt is: 1. Prompt the user and input a variable named array_size.2. Dynamically allocate an array, named array_values (use a pointer variable) exactly lar...
[3 replies] Last: Another little "oops"..... line 16 is not using your array. array_va... (by deleted account xyzzy)
Issues with using a vector
 
Hello, I am writing a program for a contact manager and I am using istream for inputting data. I need to account for the times in which a user may want to enter...
[4 replies] Last: [quote name=theforgottenone4] Thanks for your reply! Unfortunately, th... (by TheIdeasMan)
Most efficient control condition in a loop (1,2,3)
 
There was a multiple choice question on a quiz that asked the following: The most efficient control condition in a loop is... a.) a bit b.) a bool c.) an ...
[42 replies] Last: You keep arguing the point, why should int be more efficient? In the ... (by TheToaster)
Sorting problems
 
Hey guys, I came across little bit more complicated sorting function. I have results : Merginos (Females) 111 Roma Liepa 0 51 20 115 Rima Joana ...
[2 replies] Last: are you asking how to do a then-by sort? it works like you would do it... (by jonnin)
Program that uses classes and member functions...
 
Hi, So I wrote a program that uses a class named "LinearEquation" to calculate X and Y the two linear equations(formulas in the code). This is the compile log ...
[6 replies] Last: Ok I understand, that worked I appreciate the help. (by Dustin792)
by asxxx
Conversion of objects
 
Hi, I am trying to convert type of class object, please about some tips. #include <iostream> using namespace std; class Base { public: int a; Base()...
[1 reply] : What exactly do you mean by “convert”? Do you mean like cast? Ther... (by highwayman)
May 2020 Pages: 1... 1011121314... 17
  Archived months: [apr2020] [jun2020]

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