General C++ Programming - October 2015 (Page 7)

【question about class definition】
 
I wonder why there is only public member functions there but no private data members? And in line 14. why it is not " void setName(string newName)" ? Her...
[3 replies] Last: Yes. PLEASE USE CODE TAGS (the <> formatting button) when posting cod... (by AbstractionAnon)
Derived class - 'class' was not declared in this scope
 
Hello, I am receiving an error: "'binST' and 'bst' was not declared in this scope when it tries creating an object from a derived class. I'm not quite sure wha...
[1 reply] : One problem is that you have a circular dependency. b1.h includes b2.h... (by Peter87)
How to do a random word generator?
 
I have to use a prototype string randomword(int length) with #include <iostream> #include <random> #include <string> #include <time.h> using namespace...
[2 replies] Last: Those generate random strings of letters. If you are looking for some... (by Duthomhas)
by AldenB
Member intializer list error...
 
class Something { public: Something(string n) :a{ n }, b{ 10 }, c{ 10 } {}; private: string a; int b; int c; }; gives the error: error C2797: 'Somethi...
[4 replies] Last: Awesome! Tyvm! I just discovered VS 2015 existed, I'm updating now. Th... (by AldenB)
Weird output in my code :(
 
Hi everyone, Could someone very nice please check through my code when they get a chance and let me know why i am experiencing weird output and results when ...
[1 reply] : Forgot to also say, if you are going to run this code, type C or c for... (by hardwired)
by AldenB
Functions with "reference" return types?
 
example) ostream& operator<<(...) { //... } I don't understand what the reference operator is doing after the return type. Can anyone explain please?...
[4 replies] Last: I see, thank you very much! (by AldenB)
by apomin
Initializing string to a list of int values
 
#define VAL1 1 #define VAL151 151 // all values are from 0 to 254 char *str = {VAL1, VAL151, 0}; // of course it doesn't work How to initialize a string with...
[7 replies] Last: I plan to use this construction as an element of the structure: struct... (by apomin)
Program that sums bigints
 
Hi guys,im having a class project and i need ur help, i need to make a class called "BigInt" BigInt::BigInt(string digits) in which digits have to be digits or ...
[2 replies] Last: tnx!didn`t know about that command,sorry im kinda new in c++, Do u kno... (by shija93)
How to write a program that reads a content of a file, while using an array.
 
Hello. I'm still getting used to c programming. I was given an assignment to write a program that reads a file.... "Write a program that reads the contents ...
[2 replies] Last: @leryss thank you! (by leeZico)
How to get rid of global variable from an existing code?
 
How to get rid of global variable from an existing code? I've written a code and it works. But now I have to get rid of (don't use) the global variable from th...
[3 replies] Last: THANK YOU!!!! @kenmort & @MiiNiPaa (by leeZico)
How to test if a file has valid input
 
I have written a program which opens a file of integers and computes max, min, average, total. I need to implement code which tests if there is any valid data i...
[1 reply] : #include <iostream> #include <fstream> int main() { // if( std::... (by JLBorges)
by mkb555
Deep copies
 
I'm very new to pointers and linked lists, so please bear with me here. Each Polynomial object contains a linked list, and each Node of that list contains a coe...
[6 replies] Last: Oops wait sorry, I was wrong. Polynomial is the one with a destructor.... (by mkb555)
void value not ignored as it ought to be
 
I am making a program with objects and inheritance. I am getting this error: This was working fine until i changed it to use pointers to objects. error: vo...
[3 replies] Last: Thankyou ne555, Removing the * did solve the problem and it makes sen... (by scottyado)
Game adventure 2
 
1 #include<iostream> 2 #include<string> 3 #include<cstdlib> 4 using namespace std; 5 struct survivor{ 6 string choice; 7 int society; ...
[1 reply] : case 2 does not contain a statement (by Peter87)
by aeck
Hash Table String value
 
I am trying to make a hashstring function that: sum the ordinal values of the characters of the variable multiplied by their position in the string (1-indexing...
[2 replies] Last: You might also need a second ( const int ) parameter in the hashString... (by closed account 48T7M4Gy)
by kwnnyo
Saving a row of a 2D matrix in a cell of 1D matrix
 
Hello everyone! I have this problem here: Let's say that I have this matrix A : -3 0 1 1 2 0 0 1 0 And i want to create an other matrix B with: ...
[1 reply] : it is possible only if you make them whole numbers like - 3 0 1 would ... (by closed account E3h7X9L8)
Adventure game
 
1 #include<iostream> 2 #include<string> 3 #include<cstdlib> 4 5 struct survivor 6 { 7 string choice; 8 int society; 9 char string...
[2 replies] Last: Please use code tags to make it more readable. As for your problem, i... (by tallyman)
by mkb555
Can operator overloaders be member functions?
 
I'm overloading the << operator using the following prototype: friend ostream& operator<<(ostream& sout, const Polynomial& p); But I've found that using the...
[1 reply] : Operator member functions take a reference to object as first argument... (by MiiNiPaa)
Console Play a sound - best method??
 
Hey all, For an assignment in a module of my degree, I need to write a console application MIDI sequencer. What would be the best method for creating a sound...
[1 reply] : The first link you provide is literally ten years old and the guy in t... (by Computergeek01)
Instances in vector(efficient way)
 
Hi, i am trying to make a vector that contains 5 instances(Bomba1, Bomba2, Bomba3, Bomba4, Bomba5)and this is what i got. "Personajes->Ingresar_Bomba" put the ...
[1 reply] : The feature you're looking for is called "List Initialization": http:/... (by Computergeek01)
October 2015 Pages: 1... 56789... 27
  Archived months: [sep2015] [nov2015]

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