177 Topics

Member Avatar for
Member Avatar for yozzie

Alright - this is my conundrum. As a noob to C++ I am only in chapter 9 of my book, having just covered object oriented programs and the exciting world of vectors and arrays. I have an assignment that asks me to run a loop to get and calculate a …

Member Avatar for yozzie
0
2K
Member Avatar for |Mike|

Hello! I'm trying to modify opensourced application but due to lack of knowledge, I'm stuck. Explantions are in the comments of the app :-) Thanks in adavance for your support! [CODE]void CBaseGame :: FixSlots( ) { struct Struct1{ list<string> UserList; list<CGameSlot> PlayerSlots; }; list<string>::iterator IT; list<CGameSlot>::iterator TI; for( vector<CGamePlayer *> …

Member Avatar for mike_2000_17
0
229
Member Avatar for Eman84

When I open an image, I get error message: "Some text layers might need to be updated before they can be used for Vector output", and there's a warning message beside the text layer. Of course, I was trying to solve this problem all of the past days. 1- I …

Member Avatar for Armadillo
0
734
Member Avatar for failbot

I recently wrote an implementation of STL Vector as a programming exercise. The program compiles but I receive a strange error saying: [CODE] terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc [/CODE] I've never come up with this error before and am not sure what exactly should be …

Member Avatar for vijayan121
0
2K
Member Avatar for RapidFire4Life

Hi I'm having a lot of trouble with this problem. Here is the assignment... Write the definition of the function template seqSearch to implement the sequential search on a vector object. [CODE] template<class elemType> int seqSearch(const vector<elemType> &list, const elemType& item); //If item is found in the list, return the …

Member Avatar for RapidFire4Life
0
959
Member Avatar for pupucashu

The program takes a file with names and GPAs and sorts them in order of highest GPA to lowest using vectors. I cant seem to find out whats wrong with the code. Everytime i run it it says 'vector subscript out of range'. Can someone please help me? File: James …

Member Avatar for jonsca
0
423
Member Avatar for jshoot

Hi every one! I have to genarate a 2d graphic based on x,y axis. I have two vectors with the same size, and I wanna to use then to make the x and y axis. Can anyone help me? Or show a trick, or page? Thanks

Member Avatar for jshoot
0
132
Member Avatar for ravenous

Hi guys, I'm sure that the answer to this is simple, but I don't know what it is and it's bugging me. For reasons that aren't important, I'm trying to make a kind of light-ish weight array class. I want to be able to use syntax like that of [icode]std::vector[/icode] …

Member Avatar for ravenous
0
245
Member Avatar for iamthesgt

This may be a simple fix, but I have a class for a program that contains some member functions that manipulate a vector. The vector is a private member variable, and is filled from an array using a constructor. When I try to access the member functions to manipulate the …

Member Avatar for iamthesgt
0
171
Member Avatar for iamthesgt

When writing a program that uses separate compilation (I have a header file, a .cpp file that declares all the member functions of the class in thee .h file, and an application file). I used a constructor to pass the contents of a dynamic array to a vector, but it …

Member Avatar for iamthesgt
0
281
Member Avatar for iamthesgt

Okay, we had an assignment in computer class that I have been working on for awhile but what I've got so far isn't working. It seems that it may be a compiler issue, but since I can't get to a linux compiler (what the program will be evaluated on), and …

Member Avatar for iamthesgt
0
157
Member Avatar for ravenous

I have to calculate the modal value of [icode]std::vector< int >[/icode] quite often, so I thought I'd share my general method for people to look at, use and/or comment. In my case, the vectors usually contain values in the range 0 - 255. The code first creates a [icode]std::vector< int …

Member Avatar for vijayan121
0
1K
Member Avatar for Majabat

Dear All, I’m implementing a vector class that allows me to do vector arithmetic. What I’ve implemented is the following: [CODE]class mVec { private: float vec[3]; public: mVec(); mVec(const float * const parray); mVec(const float a, const float b, const float c); ~mVec(); mVec operator+(const mVec& param); mVec operator-(const mVec& …

Member Avatar for Majabat
0
155
Member Avatar for hauda67

I am creating a desktop application that will also include a calculator, similar in function to the calculator of the Microsoft Windows OS. I require some assistance in implementing the memory capability such that the user can store a number, recall the number to be used in a calculation or …

Member Avatar for Ezzaral
0
199
Member Avatar for Elgan

Hello, I am trying to read some words from section in an INI file. Then putt hem into a vector of a section vector, This is the struct and class def [code] struct elgbotsections_t { char name[30]; vector <string> phrase; }; class ElgbotManager { private: char * filename; public: ElgbotManager( …

Member Avatar for Elgan
0
218
Member Avatar for airerdem

Hi everybody, I really need that code, I have a text file 32 4 12 13 4 12 0 0 0 0 0 3 2 3 4 and I want to convert it vector or array like A[2]={32,4} B[4]={12,13,4,12} C[9]={0,0,0,0,0,3,2,3,4} The size of the vector or array can be changed …

Member Avatar for Tellalca
0
165
Member Avatar for OrangeGrover

Hello, first off thanks for reading. So my problem occurs when I try to copy an element from one vector into a second vector. The error that I get says that the vector subscript is out of range when I try to push_back that element. I only get an error …

Member Avatar for OrangeGrover
0
310
Member Avatar for jcax

Hi all, I'm trying to create two classes which each of them contain a vector of object of the other class. Below is roughly the idea of what I'm trying to do but it seems that it cannot work as it will end up into infinite recursion or something. What …

Member Avatar for jcax
0
130
Member Avatar for Basteon

Hi! I'm writing the mergesort algorithm, theoretically everything is fine in it but when the function gets to call itself the program crashes. I belive that I'm doing something worng when I pass the vector<int> as a parameter to the function. [B]procedure mergesort(T[1 .. n]) if n is small then …

Member Avatar for Basteon
0
1K
Member Avatar for harryhaaren

Hey guys, I written a base class (AudioTrackElement), and derived a class from there (Looper) and another (VolumePan). The looper class implements functionality, while the AudioTrackElement is there just so I can hold many Loopers and VolumePan objects in the same vector. The problem: I can create a [icode]std::vector<AudioTrackElement>[/icode] no …

Member Avatar for harryhaaren
0
226
Member Avatar for raheel_88

I'm having some trouble outputting a 2D vector as a grid in the Terminal. What I've done is create a class [ICODE]Grid[/ICODE] that creates a grid (in this case, a square grid), by creating a set of x and y co-ordinates whose spacing is [ICODE]dx[/ICODE] and [ICODE]dy[/ICODE]. I can then …

Member Avatar for StuXYZ
0
1K
Member Avatar for lasl0w

Hey all, I'm implementing a hash table for a spell checker and need some assistance on vector const_iterator - at least I think that's where the problem lies. Can anyone assist in diagnosing how to fix these compiler errors? I initially got this error, which i think will come back …

Member Avatar for lasl0w
0
439
Member Avatar for gpjacks

This is a program which declares two vectors of 6 elements each of type double. One vector is named weight and the other is named rate. The program uses a loop to prompt the user for a weight in ounces and a postage rate for that weight and then stores …

0
239
Member Avatar for gpjacks

So, I am in the mid part of my C++ class and am having trouble with a vector project at the end of the chapter. I don't expect the answer, but if someone would point me in the right direction I would greatly appreciate it :) #1). Write a loop …

Member Avatar for gpjacks
0
261
Member Avatar for dorien

Hi, I want to copy a row from a 2d vector in an existing 1d vector. I found a similar tread, which copies into a newly defined vector as such: [CODE]vector< data_type > copyRow( vec2d[3].begin(), vec2d[3].end());[/CODE] Now I want to change this code, so that copyRow already exists. My idea …

Member Avatar for dorien
0
1K
Member Avatar for RobBobSmith

Hello all, I'm having trouble with making a 2d vector array class. Would anyone have time to help with a couple of questions? I think my problem is with overloading (). I notice that this: [CODE]template <typename T> T& Array2d<T>::operator() ( int x, int y) { if( x >= rows …

Member Avatar for RobBobSmith
0
186
Member Avatar for stubee_1975

Ok I've created the class Weapon below and I now want to create a vector of Weapons, how do I do this? class Weapon { public: Weapon(); // Methods private: // Data members. std::string mWeaponName; int mDamage; float mCost; }; #endif //WEAPON_H

Member Avatar for stubee_1975
0
206
Member Avatar for crossbow25

[CODE] #ifndef VECTORBINARYTREE_H #define VECTORBINARYTREE_H template<typename Object> class ArrayVector{ private: int capacity; int sz; Object* a; protected: void overflow() { capacity*=2; Object* b=new Object[capacity]; for(int i=0;i<sz;i++) b[i]=a[i]; delete []a; a=b; } public: ArrayVector(int initCap=16){ capacity = initCap; sz=0; a = new Object[capacity]; } int size() const {return sz;} bool isEmpty() …

0
84
Member Avatar for FumarMata

Hello I want to pass a bidimensional vector to the constructor of all instances of [ICODE]MyClass[/ICODE]. All instances must use and share and modify the same vector. And I want to keep a reference to that [ICODE]main_vector[/ICODE] to use it later in the program I am passing it by reference …

Member Avatar for Fbody
0
199
Member Avatar for adaniel058

I can not figure out why my code is reading in data to my vector in funny ways. I have added the input file and necesary class to test. It seems to be skipping values in the input file and also adding things to seperate places in the vector instead …

Member Avatar for kramerd
0
228

The End.