I did some don't know how to read into the vector, need help on this assignment: Rich Software Inc. has hired you for an internship position to create new payroll software for their employees. Your goal is to create a program that reads the newdata.txt file with their salaries. After that, the user can select from a 4 choice menu that handles the user’s choices as descried in the details below. The program should display the menu until the user selects the menu option quit. Add the newdata.txt file inside your project. Your program must be able to read any …

Member Avatar
+0 forum 0

When I try to compile my code in visual basic 2010 it gives me the error 1903 and when I compile the code in Code::Blocks it opens the standard template library's algorithm.h file and takes me to line 2163 if (*__i < *__first) I don't want to modify anything here, but I can't figure out what its wanting me to do. How can I fix this problem? Here is my code for reference: #include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <string> using namespace std; //Template that puts things where they go. template <class T> void produceReport(string report, T …

Member Avatar
Member Avatar
+0 forum 7

Hey everyone, So, I need help understanding why I'm not able sort my code: here is my code (so far) for my selection sort. I have only written the iterative form of Selection Sort, but I know how to do it recursively as well (which is required for my homework). When I print it out, it just prints out the unsorted array AFTER I call the selection sort. Here is my full code so far: main.cpp #include <iostream> #include <vector> #include <cstdlib> #include <ctime> #include "SelectionSort.h" using namespace std; template <class print> void printData(print a, int sizeOf); template <class randomData> …

Member Avatar
Member Avatar
+0 forum 1

Please bear with me, this is my first post So, I have this superclass called A. And I've 2 subclasses A1 and A2. A has attribute name. A has function toString(). A1 inherits name, and has attribute hair. A1 has a method toString() which goes: string A1::toString(){ string stringA= A::toString(); stringstream info; info<<stringA<<" "<<hair; return info.str(); } A2 is the same as A1, except that it has face instead of hair. it's toString goes info<<stringA<<" "<<face; In my main(), vector<A*> vector; Then, I have a function to add objects void addA1 (vector<A*> &vector) void addA2 (vector<A*> &vector) both use push_back, …

Member Avatar
Member Avatar
+0 forum 2

I have this weird problem. If my constructor is [header] class Book { private: vector<string>Entry; public: Book(); [cpp] Book::Book(){ Entry.push_back("0"); Entry.push_back("1"); Entry.push_back("2"); The weird thing is that it does not update when I do more .push_back. I use: void Book::addItem(vector<string>newItem) { for(int f=0; f<Entry.size(); f++) { Entry.push_back(newItem[f]); cout<<Entry[f]; } } when i display all the items in Entry, only the ones in the constructor is displayed, and not all the additional ones I add through addItem(). I don't know what's wrong...!!! How to fix???

Member Avatar
Member Avatar
+0 forum 1

Hi everyone. I've been struggling with a quicksort implementation here. I think - scratch that - I know i'm overrunning an array (erm, vector) based on how it explodes, but I honestly can't see it and I have no debugger. I slept on it but fresh eyes didn't get me anywhere. I've been digging around online for a while but there are a thousand different ways to do quicksort and it just ends up being confusing to keep it all straight. Oh and two things to note: -Yes, I have to use vectors. I've no idea why. -There are global …

Member Avatar
Member Avatar
+0 forum 4

I have a declaration of a 2d vector: vector<vector<int> > data; I want to add several times in an server-client problem an array of 25 elements. I donnot know how many times i must add that array(which changes its values). How can i add that element to the vector without declarating the initial size of the vector?? double inputs[23] ={.....}; Any idea about this???Thanks in advanced!

Member Avatar
Member Avatar
+0 forum 1

I'm having some trouble making my snake move :D I can move one point in any direction but the whole body of the snake is where I'm confused , if(a == (char) 119 || a == (char) 87 || a == 72) { y=y--; gotoxy(x,y); PrintVector(v); } thats works just fine if my vector consists of only one point , but other than that it doesnt work , I know if I Want its body to move right I gotta use puch_back and pop_back but I just need a little help or a hint :D another thing i'm making my …

Member Avatar
Member Avatar
+0 forum 16

I decided to learn C++ STL and I was exprimenting with STL containers. I saw this example [here](http://www.cplusplus.com/reference/stl/vector/insert/): // inserting into a vector #include <iostream> #include <vector> using namespace std; int main () { vector<int> myvector (3,100); vector<int>::iterator it; it = myvector.begin(); it = myvector.insert ( it , 200 ); myvector.insert (it,2,300); // "it" no longer valid, get a new one: it = myvector.begin(); vector<int> anothervector (2,400); myvector.insert (it+2,anothervector.begin(),anothervector.end()); int myarray [] = { 501,502,503 }; myvector.insert (myvector.begin(), myarray, myarray+3); cout << "myvector contains:"; for (it=myvector.begin(); it<myvector.end(); it++) cout << " " << *it; cout << endl; return 0; } …

Member Avatar
Member Avatar
+0 forum 2

Yes, I know that this is homework. But I need help. This is code the teacher gave us few days ago. This is a header file. And I needed to do the following: My problem is that I didn't know how to use my vecetor in my .cpp file. How to add the names into the vector? I now it should be kind of like vectorname.push_back("name"); ??? How do I call my vector to print the names? I don't know I'm lost and need help. I know that there is people that don't want to help with homework but this …

Member Avatar
Member Avatar
+0 forum 2

I have a method that returns void. say: Public void CreateRectangle(double z, double y, IRectangle rectObj) { Vector3d recPos1 = new Vector3d() recPos1.X = 0; recPos1.Y = some double vale; Vector3d recPos2 = new Vector3d() recPos2.X = some double value; recPos2.Y = 0; rectObj.SetVectors(recPos1, recPos2); } now, in my unit test i just want to verify that SetVectors() method has been called on object rectObj. I have written a moq unit test but it fails. My method looks like this: [Test(Description = "")] public void TestCreateRectangle() { double xPos = default(double); double yPos = default(double); myClass objMyClass = new myClass(); …

Member Avatar
Member Avatar
+0 forum 1

Write a statement that declares and stores the elements of the following array into a vector object: char vowels[5]={'a', 'e', 'i', 'o', 'u'}; I think this is what I need, but I want to verify this. [CODE]char vowels[5]={'a', 'e', 'i', 'o', 'u'}; vector<vowels> vowelsList (vowelsArray, vowelsArray +5);[/CODE]

Member Avatar
Member Avatar
+0 forum 2

Hey, I was having trouble making my vector print out randomly generated numbers in ascending order. Can I please get some help?. This is my assignment "Write a program name count.java that will use a Vector to store 10,000 randomly generated numbers (ranging from 1 to 99) Now sort the vector in ascending order. Also, count the amount of 1's, 2's, 3's ... 98's and 99's in the vector. 1. The program should display the sorted vector on the screen. 2. The program should also display the amount of 1's, 2's, ..... etc. on the screen. " And this is …

Member Avatar
Member Avatar
+0 forum 16

Hi i'm making a function that will return make a series of strings and perform a function returning a value for each. I've stored the strings in one vector v, and the integer values in another v2. Then it is supposed to return the string that corresponds to the smallest value in v2. I'm trying to pushback the vector for each time the for loop is run, but I get an error saying there is no such function "push_back" to call. What am I doing wrong here? I'm compiling on quincy by the way. Thanks for the help! [CODE]string mutated_chooser(string …

Member Avatar
Member Avatar
+0 forum 5

Hi!! my application have 2 frames including tabel 1,tabel 2 when run time i insert values though textfileds to tabel 1 ,after inserting 5 or more then i click next button then display other frame with tabel 2 and tabel 2 must auto filled. my problm is last row(i already insert to 5 or more row to tabel1) only displaying in tabel2 here is my code: tabel1 [CODE] package tabels; import java.util.Vector; import javax.swing.table.DefaultTableModel; public class tabel1 extends javax.swing.JFrame { /** Creates new form tabel1 */ public tabel1() { initComponents(); setLocationRelativeTo(null ); } /////////THIS ARE AUTO GENRETECODES///////// @SuppressWarnings("unchecked") // <editor-fold …

Member Avatar
Member Avatar
+0 forum 1

I am trying to display the sNames vector. I am not sure if I am storing the information correctly. Any help would be greatly appreciated. Also I am trying to get an average for each students exam grades and a class average, and I am not sure how to go about this. [CODE] #include <iostream> #include <string> #include <vector> #include <conio.h> #include <algorithm> using namespace std; struct Student{ string fName; string lName; vector<double>exams; }; int main(){ int count; const int NUM_EXAMS = 5; Student tempFName, tempLName; double tempExam; int numStudents = 0; vector<Student> sNames; vector<Student>::iterator iter; cout << "Number of …

Member Avatar
Member Avatar
+0 forum 3

Hey - I'm looking for something similar to using vectors and pointers that I've used before in C++; unfortunately, it doesn't seem like there's an equivalent function in VB.net. What I have is a copy of the array behind a multi-line Rich Text Box, and I need to separate the words from each line (or element of the array) so I can analyze each one separately. In C++ I would do something like this, so I could continuously expand as needed: [ICODE]char[] delim = {' '}; //Character that it splits the string at //(of every occurence) struct lines { // …

Member Avatar
Member Avatar
+0 forum 6

Hi! It's me again :) I have failed with my C++ code once again. This time it's with vectors. [CODE]string show_actions(){ vector<string> actions; actions.push_back("end"); actions.push_back("hunt"); vector<string>::const_iterator iter; cout <<"All of the possible actions are : " << endl; for(iter = actions.begin(); iter != actions.end(); ++iter){ cout << *iter << endl; } } [/CODE] There is supposed to be an error somewhere in that code. When I try to compile it prints out [CODE]end hunt Segmentation fault[/CODE] If you know what to do, please let me know. I haven't got the slightest clue If you need the rest of the code, …

Member Avatar
Member Avatar
+0 forum 2

Is it possible to assign a variable to be a random vector. The only syntax I could find was rand.jumpahead but further research did not seem promising. Thank you, Suhail

Member Avatar
Member Avatar
+0 forum 2

I have a the following snippet of code [CODE]string const& symbol::at(int index) const { assert(index<symbol_data.vector::size()); return symbol_data.vector::at(index); }[/CODE] This does not compile successfully, instead, I get complaints about [CODE]error: ‘template<class _Tp, class _Alloc> class std::vector’ used without template parameters[/CODE] Now, I think this has something to do with the fact that I'm returning a const reference to an object that this function is treating as const. How can I modify my two lines of code to satisfy const correctness?

Member Avatar
Member Avatar
+0 forum 11

Hi All, Is it possible to bind an array or a Vector with a event listener? For an example if we add an element to the Vector or remove from the Vector, can I use an event listener to track the changes? Thanks a lot in advance. Cheers..!!

Member Avatar
Member Avatar
+0 forum 5

Hi, I am trying to write a program for my mum who is a teacher, the program needs to be able to store students information like their name address SAT scores etc. I have a basic background in c, but i decided to try and implement this program using c++. what i have done so far compiles but the program keeps crashing whenever i try to enter the section of the program where i have to add students into my vectors. Here is my code [CODE = c++] #include "stdafx.h" #include <iostream> #include <string.h> #include <vector> #include <string> #include <fstream> …

Member Avatar
Member Avatar
+0 forum 10

ok, so i want a program that just says back to the user their input. the users input will be more then one word, so there will be whitespace. when i use string as a class for the input, then it only gives back the FIRST word of the input.... so i decided to use a vector, but i suck at them... this is what i tried.. but on line 10, idk what to do :/ thnx! [CODE]#include <iostream> #include <string> #include <vector> using namespace std; int main() { vector<string> s; string v; cin >> v; s.push_back(v); cout << endl …

Member Avatar
Member Avatar
+0 forum 5

Alright, I suspect there is already a solution here somewhere on the forums but I'm not quite sure I'm searching for the right terms so I hope you dont mind me asking the question anyway. My goal is to make a constructor for a class called building. instance variables are: [CODE]int _id; //id of the building int _floors; // numbers of floors int _rooms_per_floor; //rooms per floor std::vector<std::vector<person*>> _assignments //this represents the building[/CODE] now the constructor so far looks like this: [CODE]building::building(int id_, int floors_, int rooms_per_floor_) : _id(id_), _floors(floors_), _rooms_per_floor(rooms_per_floor_) { // TODO: creating the 2d vector _assignments with …

Member Avatar
Member Avatar
+0 forum 10

Hello All. This is my first post. I would really appreciate if you can help me in a project I have to complete as soon as possible anyway, the thing is this: I have a bunch of numerical data in any format (say an excel page with 3D vectors, or a text file with the same 3D (x,y,z) vectors) and I have to represent them in graphical form (as for example arrows). What tool do you think I should use? I know this is not exactly about c++but couldnt find an appropriate place Thanks a lot in advance Kansai

Member Avatar
Member Avatar
+0 forum 4

Hi everyone, My question is: I have two vectors, for example vectorA and vectorB, vectorA is filled with randomics values, like 23, 43, 54, etc, and its have 1000 members, like vectorA[0], vectorA[1], etc. My vectorB descending of vectorA, I use the "push_back" function to take the values of vectorA, but I specificate wich ones values I want, like this: [CODE]std::vector< double > vectorA ; std::vector< double > vectorB; double c2 = 100; while( c2 < 500){ vectorB.push_back(vectorA[c2]); } [/CODE] But when generate the vectorB, its have 1000 members, the vectorB[0] is equal to the vectorA[100](what I wanna in this …

Member Avatar
Member Avatar
+0 forum 5

Hi all, I'm trying to create code which manipulates data within a vector. The vector contains floating points which store consecutive 3D values. For example element 1 stores object 1 x coords, element 2 - object 1 y coords, element 3 - object 1 z coords, element 4 object 2 x coords etc. My problem, is I am trying to update the vector by replacing the values for the 3rd object x,y and z with the second objects, and then putting in new data for the first. [CODE]void shuffleArray() { int a = 4; for (int c = 0; c …

Member Avatar
Member Avatar
+0 forum 1

Hi, i have to write a program to allow the user to input 5 candidate names and the number of votes they received, then it calculated what percent of the vote each candidate received and then ten tells the user who won. I think I've got a code that will work but i have one small problem. On lines 19 and 37 of my test file... [CODE]candidate.insert(i, name);[/CODE] and [CODE]votes.insert(i, vote);[/CODE] both candidate and votes say the are undeclared so for some reason they aren't being accessed in the header file and i don't know why, am I using .insert …

Member Avatar
Member Avatar
+0 forum 3

Hey everyone, In my COMP 208 class, I was asked to do the following: "Redo Lab 2 Problem 2, only this time use vectors to hold the names and gpa’s instead of arrays. So you will work with 2 vectors, one holding the gpa’s (type double) and the other holding the names (type string)." THIS IS THE PROBLEM I NEED TO CONVERT TO VECTORS: "Your program sorts the students ascending by gpa, and prints the sorted list including names. To keep the names with the numbers use parallel arrays, one for the names, the other for the numbers. Sort the …

Member Avatar
Member Avatar
+0 forum 6

Hey folks, just a quick question i can't seem to find the answer to. If i overwrite a container with a pointer in it, does the pointer and therefore the object it points to still exist, and would that be considered a bad handling of memory. For instance. I have 2 vectors pointers to objects: [code] vector<DNA*> m_vPopulation2; vector<DNA*> m_vParentPop2; [/code] I know they are the same size, although would that matter?. And i want to make m_vPopulation2 = m_vParentPop2. Basicly i want all the elements inside population to become the elements inside ParentPop. Could i just write: [code] m_vPopulation2 …

Member Avatar
Member Avatar
+0 forum 8

The End.