73 Solved Topics

Remove Filter
Member Avatar for
Member Avatar for BirdaoGwra

Hi, I am getting an error while making a vector. frame.h #include <wx/wx.h> class Frame : public wxPanel { public: Frame(wxPanel* parent, int xx, int yy); ~Frame(); private: int x; int y; } frame.cpp #include "frame.h" Frame::Frame(wxPanel* parent, int xx, int yy) :wxPanel(parent) { x = xx; y = yy; …

0
839
Member Avatar for prahesh

class Data { string name; string ID; public: Data(){cout<<"Data"<<endl;} }; class info{ string name; string ID; public: info(){cout<<"info"<<endl;} }; Two classes defined above. Now I want to create a vector of type std::vector<Data obj1, info obj2> container; further I want to use the vector features using the vector container. How …

Member Avatar for prahesh
0
300
Member Avatar for ddanbe

For my own use, I'd like to develop a small Vector and a Matrix class, independent of some big libraries that exist out there. My question is: Should Vector and Matrix stay two independent entities or should I derive a Vctor frm a Matrix or a Matrix from a Vector? …

Member Avatar for mike_2000_17
0
357
Member Avatar for Auroch

Hello everybody! I'm trying to display the result of difference of two-dimensional vectors using friend overloading. Builder shows the following error after compilation (line 40). What should I change for in my code in order to find the problem? Thanks in advance. **[C++ Error] 05_Part.cpp(40): E2034 Cannot convert 'double' to …

Member Avatar for Auroch
0
240
Member Avatar for Milton Neal

I'm working on a bit vector class that I'm using in a current project. Basicly BitVector is a container class for storing and manipulating data a bit level. I have two member fuctions for "setting" and "getting" bits at a given index. // Returns the bit at the specified index. …

Member Avatar for Milton Neal
0
307
Member Avatar for Auroch

Hello, I have the following problem: Entering coordinates of points on a plain with keyboard (as rows x,y). Analysing this coordinates. Replacing coordinates in vector (point - structure data type). Then calculating distance from the first point to all another points. I've written the code of this problem using arrays …

Member Avatar for Auroch
0
2K
Member Avatar for ravi_14

vector <int> a; //first vector vector <int> b; //second vector vector <int>::iterator i; //iterator for first vector vector <int>::iterator i1; //iterator for second vector //reading of first vector int temp; while(cin>>temp) { a.push_back(temp); } i=a.begin(); while(i!=a.end()) { cout<<*i<<" "; i++; } //end of reading first vector //reading of second vector …

Member Avatar for Banfa
0
205
Member Avatar for ravi_14

for(i=a.begin();i!=a.end();i++) { cin>>*i; } for(i=a.begin();i!=a.end();i++) { cout<<*i; } above code works fine but when i use while loop to display vector , program crash. while(i!=a.end();) { cout<<*i; i++; }

Member Avatar for Banfa
0
204
Member Avatar for uonsin

Hi everyone and thanks in advance for the help. I have the following class that throws an error on compiling where i declase a vector of pointers I have an Engine class that I want to host multiple scenes objects stored in the vector sceneList and then pass which ever …

Member Avatar for uonsin
0
341
Member Avatar for Damian_2

Okay so I have an `inventory` class that accesses a static vector from my base class `MainShop`. I also have a `SwordShop` class which inherits from `MainShop`. (Both Inventory and SwordShop are derived classes). //SwordShop class void SwordShop::Shop { //I have a setter function where it takes an integer and …

Member Avatar for Damian_2
0
332
Member Avatar for narlapavan

class A{ Vector<String> s = new Vector<String>(); } public class Vec { public static void main(String[] args) { A a = new A(); a.s.add("String1"); a.s.add("String2"); a.s.add("String3"); a.s.add("String4"); a.s.add("String5"); Vector<A> vecA = new Vector<A>(); vecA.add(a); System.out.println("Size of vector is "+vecA.size()); // here i am getting size one a.s.clear(); a.s.add("String6"); a.s.add("String7"); a.s.add("String8"); …

Member Avatar for scudzilla
0
267
Member Avatar for toneranger

Hi, Imagine a vector of structures with each structure containing various variables. struct Data { double x double y double z } vector<Data> Dataset vector<Data>::iterator it //input some data from a file into DataSet How can I iterate over this vector, comparing say, x at the nth row to the …

Member Avatar for toneranger
0
304
Member Avatar for ktsangop

Hello everyone! I would like your help regarding this: I have a tuple vector which i must iterate through, and accessing the vector data to decide wether to erase or not the current vector element. My code : typedef tuple <int, CString, int, int> pc_data; vector <pc_data> pc_vec; //Assume that …

Member Avatar for ktsangop
0
6K
Member Avatar for Griff0527

Hello everyone. I am working on creating a stub that would allow me to swap out various sorting algorithms so that I can "plug in" the algorithms and run the various sorts. The below code is for Insertion Sort (yes, I know it is the slowest possible sort), but once …

Member Avatar for Griff0527
0
531
Member Avatar for Alexkid

Hi there I need help writing a data structure to hold and assign data to a particular unique ID. I think I want an vector of structures: struct Data { int ID; double latitude; double longitude; int speed; int altitude; }; I receive messages in the above format, they can …

Member Avatar for Gonbe
0
263
Member Avatar for darkeclipse8

My professor asks me to program the Game Of Life with some required and I find unnecessary classes. But anyhow as I am coding and running the program midway I run into this problem void Life::setup_grid() { cout << "Size of Grid: " << grid.size() << endl; cout << "rows: …

Member Avatar for NathanOliver
0
384
Member Avatar for Geowil

I decided that before I would actually write the code for my planned inventory system in a game I am writing I would test it out in a small project first to make sure I know what needs to be done and if I needed to change anything. So I …

0
95
Member Avatar for rahul.ch

import java.util.*; class SampleA { } class SampleB extends SampleA{ } class SampleC extends SampleA{ } class VectorDemo { public static void main(String r[]) { Vector<SampleA> v = new Vector<SampleA>(); v.add(new SampleB()); v.add(new SampleC()); SampleC rect = v.get(2); } } The output says "Incompatible types. Found SampleA, required SampleC. SampleC …

Member Avatar for rahul.ch
0
222
Member Avatar for userIT

Given the trace program below. I basically need to store a 1 or a 0 to the corresponding `a[r[i]]` the problem is I need to be able to keep track of the index of vectors zero and one to check the last index that was used for each vector. For …

Member Avatar for userIT
0
179
Member Avatar for resmi sanker

can u give me some details regarding this paper?can u plz tell me what is a master defect record and feature association?

Member Avatar for rubberman
0
148
Member Avatar for Hazardous_Byte

Hello everyone! I am having a bit of an odd problem here. So, on my Visual Studio project, I decided to use a precompiled header. This didn't seem to cause a noticable problem up until today. I have a small segment of code that is supposed to remove one element …

Member Avatar for Hazardous_Byte
0
669
Member Avatar for sandz24

#include <iostream> #include <vector> using namespace std; template< typename T > using matrix = vector< vector<T> > ; I saw this code snippet while searching for templates. I was wondering why there's a word "using". What is it for? Thanks :)

Member Avatar for sepp2k
0
164
Member Avatar for dancks

I don't really have an explanation and whoever thought that this new posting format was the way to go... idk what to say. I really don't like it. I can only post so much lines of code before something happens to the window and I can't scroll all the way …

Member Avatar for mike_2000_17
0
257
Member Avatar for JamesArhy

Hey Guys, I'm building an asteroids-like game and I'm needing to be able to apply the same operation too all of the different "aliens" on the screen. When I had two aliens on the screen I performed all of the functions manually but that is bad program design. I created …

Member Avatar for sfuo
0
794
Member Avatar for sampsont

I want to re-use a vector<short> over and over in a performance critical loop. I only need the vector **size** to be reset to zero at the end of the loop. I'm worried that the myVector.clear() takes time to actually clear all the memory. Also, does the myVector.reserve() survive the …

Member Avatar for sampsont
0
641
Member Avatar for Lord_Migit

Hi there. I am having some trouble trying to figure out how to delete a pointer that is held in a vector. int main() { vector<Test*> iVector1; vector<Test*> iVector2; vector<Test*>* pVec1(&iVector1); vector<Test*>* pVec2(&iVector2); pVec1->push_back(new Test(11)); pVec1->push_back(new Test(12)); pVec2->push_back(new Test(23)); pVec2->push_back(new Test(24)); //delete iVector1.at(0); delete iVector1[0]; iVector1.at(0) = new Test(21); pVec1->at(1) …

Member Avatar for Lord_Migit
0
247
Member Avatar for Sunshine2011

#include <iostream> #include <vector> #include <iterator> using namespace std; class members { private: int Age; int Money; public: void setAge(int age) {Age=age;} void setMoney(int money) {Money=money;} int getAge()const {return Age;} int getMoney()const {return Money;} members(int age=0,int money=0): Age(age),Money(money) {} }; int main() { vector<members>v_members; for(size_t i=0,z=0;i<10;++i,++z) { if(z!=5) { v_members.push_back(members(50,70)); …

Member Avatar for Sunshine2011
0
219
Member Avatar for Lucaci Andrew

Hi. So my problem is that I can't save into a vector throughout a function, but I can save directly in the vector. /* * asd.cpp * asd.cpp is licensed under GNU GENERAL PUBLIC LICENSE * Created on: May 3, 2012 * Author: sin */ #include <iostream> #include <string> #include …

Member Avatar for Lucaci Andrew
0
165
Member Avatar for JOSheaIV

So first of all let me say I am pretty new to C++ and find it very difficult to learn (especially when compared to say C#) Anyway I am working on a program that requires the use of a 2D array or a similar container. After talking with a professor …

Member Avatar for JOSheaIV
0
3K
Member Avatar for sota

Hi all, I ve been seeking a tutorial,article etc. about 2D cliext::vector . These are using <cliext/vector> library and cliext namespace. At once i need 2d vector decleration and its erase method to remove all rows which are full of zeros. Any help 'll be greatly appreciated.

Member Avatar for sota
0
367

The End.