General C++ Programming - November 2016 (Page 9)

Getters and Setters with std::vector private members
 
Hi People, Please correct me if i am wrong. From this code, and for my surprise, I realized that the getter member function returns the std::vector by value...
[7 replies] Last: Finally I could see my mistake: I have to declare v2 as reference. ... (by dariodem)
c++ two dimensional array into one
 
hay guys i need to make a two dimensional array into a one. i think i have to use recursion? thanks
[1 reply] : Is this what you meant - the make1d( ) function below? You can play ar... (by lastchance)
How to set value position in vector?
 
How can I set value position in vector without overwriting an value? for example, I have a vector with a, b, c, d in it. And I want to add o at position 2. I...
[1 reply] : Is this insert() what you're looking for? http://www.cplusplus.com/r... (by wildblue)
Weird output of ""+'b'
 
Hello, I wrote the following line in c++: cout << ""+'b' << endl; The output is '[', which is quite weird. Can anyone help to explain the output? Thanks...
[3 replies] Last: A string literal is actually const character array with a null termina... (by boost lexical cast)
Overloading Operator
 
I need to compare objects in a program. I need to provide the operator overloading for the operator ">" so that Pokemon can be compared based on its instance v...
[3 replies] Last: Another similar way: .h bool operator>(const Pokemon &) const; .cp... (by boost lexical cast)
Urgent help needed
 
An investor is facing the task of choosing the most economically viable project between 4 different manufacturing companies (A, B, C and D). Below is the table ...
[4 replies] Last: "A mechanical student". Is that an electric, nuclear or steam powered ... (by closed account 48T7M4Gy)
by zandy
Vectors
 
Can somebody please help me with my vector and sorting functions. the trim and program are working but i need to output my file in "report.txt" with sorted acco...
[1 reply] : http://www.cplusplus.com/reference/algorithm/sort/?kw=sort (by closed account 48T7M4Gy)
Overloading Operator
 
I need to compare objects in a program. I need to provide the operator overloading for the operator ">" so that Country can be compared based on its instance va...
[1 reply] : http://www.cplusplus.com/forum/general/202818/ (by closed account 48T7M4Gy)
by RovelC
Outputting Values in Selective Array Indexes
 
Hi All, I need your help in working out this problem. I want to print that desired output but i'm struggling with the logic. [ * ] [ * ] ...
[2 replies] Last: #include <iostream> int main() { constexpr std::size_t NROWS = 6... (by JLBorges)
by ubaidm
The sstream wouldn't read twice..!!!
 
#include <iostream> #include <string> #include <sstream> using namespace std; int main () { int a =0; string mystr; float price=0; int quantity=0; do{...
[4 replies] Last: Thank you..!! (by ubaidm)
How to not print the positive sign in a non-US locale
 
Hi, I am using a non-US locale that defines the positive sign as "+" but I don't want it displayed... However I am having trouble and the solution I found se...
[no replies]
Find an element in sorted rotated array
 
I got this problem in an interview. I thought my solution was right but the interviewer said I was not using the sorted property of the array. I can see that I ...
[2 replies] Last: oh, got it now, thanks! (by funprogrammer)
More support in C++, is it comming?
 
I'd like to see more support functions in C++, like: * XML support * Objectify all similar functions like string to number and number to string(formatted al...
[4 replies] Last: More information: How Non-Member Functions Improve Encapsulation ... (by JLBorges)
by cppppc
Complexity analysis (recursion)?
 
Hi!! How you'd analyse functions like this one below?(details please) //***please ignore the declaration of arguments**// int insert(arg1(array), arg2(size), ...
[2 replies] Last: Thanks a lot for your time and for replying! (by cppppc)
Setting std::vector elements according to a std::vector of indexes
 
Hi People, I want to do -in the best possible way- something like this python line, in c++ by means of std::vector v1 = 1 That is: v1 elements are set...
[4 replies] Last: Thanks JLBorges! I thought there was a prefabricated way to do the co... (by dariodem)
by bozmin
List and file
 
I have a store (txt) file that contains element . ex: V 4 Potato 2 Tomato 1 carrot 3 onion 1 F 2 Banana 5 Apple 2 F 3 Orange 2 Strawberry 5 ...
[1 reply] : just take each of those in a char array if the second element is '\0'... (by leryss22)
by qq387
Finding a tree successor with a given key
 
I am trying to write a function that will return the next smallest element key greater than the parameter q when called in a binary balanced tree The code work...
[1 reply] : This implementation doesnt look really efficient here I have made you ... (by leryss22)
BST Insert
 
Been working on a program, that is supposed to read in data from a text file; first/last name, ssn, mom ssn, dad ssn, and friends. Reading in the values is not ...
[2 replies] Last: What you suggested in the same errors of not being able to convert Per... (by CubiksRube)
by DaviFN
How to (fastly) scan memory?
 
Hello everyone! I need to write a function that searches the memory of a process (I'm injected to it, with a DLL) for a specific array of bytes. I wonder the...
[6 replies] Last: Yes, typo (corrected now). Should have been (mbi.Protect&pmask) Tha... (by JLBorges)
November 2016 Pages: 1... 7891011... 23
  Archived months: [oct2016] [dec2016]

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