177 Topics
|
|
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 … |
|
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 *> … |
|
|
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 … |
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 … |
|
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 … |
|
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 … |
|
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 |
|
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] … |
|
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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& … |
|
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 … |
|
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( … |
|
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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 |
|
[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() … |
|
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 … |
|
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 … |
The End.