177 Topics

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 johans22

vector<vector<double>> v2d(2, vector<double>(3,0.0)); How later on reset all elements back to 0.0?. How to clear vec entirely, free memory?. Are there any performance degradation in using vector arrays verus conventionl arrays using new or malloc?.. What can be done to minize such degradation if any?.

Member Avatar for ravenous
0
296
Member Avatar for DS9596

Can you tell me what's wrong with it because it's not running on visual studio and I need it right now??? #include <iostream> #include<vector> #include<algorithm> #include<limits> #include<fstream> #include<string> using namespace std; class PayRoll { private: vector<int> salaries; public: PayRoll(); bool searchSalary(int salary); void generateStats(); void printSalaries(); }; PayRoll::PayRoll() { ifstream …

Member Avatar for cgeier
0
178
Member Avatar for can-mohan

Guys, In below code after reading string values from vector , I can have output like("VarID","flag","count") for(int i=0; i < v.size(); i++){ cout<<v[i]<<endl; } All are (varID,flag and count)are string literal , now i need to populate the structre with this string literal. where VarID = int,flag=bool, count=Int. Can anybody …

Member Avatar for tinstaafl
0
294
Member Avatar for Auroch

Hello everybody. I'm trying to write program with vectors and iterators. Coordinates X and Y are entered from keyboard (as structure) and placed in vector of points. It's necessary to display coordinates with maximal X and Y. This code was compiled but not display maximal X. What should I change? …

Member Avatar for Lucaci Andrew
0
273
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 shelton22

I have declared, map<int, vector<int>> abcmap; map<int,vector<int>>:: iterator itmap; vector<int>SPLINKS; SPLINKS contains: 1 3 4 abcmap contains; 1=> 1 2=> 2 6 3=> 1 2 4 I want to iterate both SPLINKS and abcmap to find and erase elements that do not match in both containers; ie after execution; 2=>2 …

Member Avatar for shelton22
0
275
Member Avatar for shelton22

I have delared two multimaps such as; multimap<int,vector<int>> allpathsmap; multimap<int,vector<int>>:: iterator itapm; typedef pair<int,vector<int>> pairapm; multimap<int,vector<int>> graphtextmap; multimap<int,vector<int>>:: iterator itgtm; typedef pair<int,vector<int>> pairgtm; And I wrote the following code to traverse the values of multimaps to print the key; for(itgtm=graphtextmap.begin(); itgtm!=graphtextmap.end(); ++itgtm) { for(itapm=allpathsmap.begin(); itapm!=allpathsmap.end(); ++itapm) { cout << endl …

Member Avatar for nullptr
0
204
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
305
Member Avatar for mystycs

Is there a way to sort a vector with a class that has an int variable? I want to have my vector sorted and printed in console. I want to be able to sort the vectors. Say i create a bunch of vectors here on user input `vector<PCB> Disks2[DiskDevices];` Basically …

Member Avatar for Schol-R-LEA
0
412
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 fadoua_1

Hi, I created a structure Vector and implement some functions to make the new defined type (vector) dynamically allocated and resized (inspired from the C++ implementation of the dynamic arrays : vector). I need to assign a structure to every vector element but I am not sure that I am …

Member Avatar for Ancient Dragon
0
380
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
203
Member Avatar for janith.amarawickrama

I rote this code in my program JSONNode::const_iterator iter = root.begin(); for (; iter!=root.end(); ++iter) { const JSONNode& arrayNode = *iter; std::string type = arrayNode["type"].as_string(); if(type == "node") { std::string id = arrayNode["id"].as_string(); double lat = arrayNode["lat"].as_float(); double lon = arrayNode["lon"].as_float(); Node node; node.SetId(id); node.SetLatitude(lat); node.SetLongitude(lon); nodesMap.insert( std::pair<std::string, Node>(id, node) …

Member Avatar for Banfa
0
509
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
340
Member Avatar for Damian_2

Okay so I have a class `Student`, which takes a number and a vector as a parameter for the constructor. Everything works well, until I output the values of the vector for every instance. The problem is that the same vector is being shared with EVERY instance I create, but …

Member Avatar for rubberman
0
426
Member Avatar for narlapavan

my code: class A{ Vector<String> s = new Vector<String>(); } public class Vec { /** * @param args the command line arguments */ 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()); …

Member Avatar for milil
0
212
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 jonathan710

// Expect to print values of arr[0] to arr[4] #include <iostream> #include <vector> using namespace std; int main() { vector<int *> ptrList; int arr[] = { 0, 10, 20, 30, 40 }; int * ptrArr = arr; for( int i=0; i< 5; i++ ) { ptrList.push_back( ptrArr+i ); } vector<int …

Member Avatar for nullptr
0
253
Member Avatar for coiseng

Hi, I'm newbie with C++ and I found an example which I need http://ideone.com/Eikbr4 But I've a question, how do I seperate this piece of code into .h and .cpp.. I tried to do something similar on my own but I'm having struggling with it after multiple try.. I've read …

Member Avatar for tinstaafl
0
311
Member Avatar for skyyadav

How to sort vector<int> v{3,2,7,6,5,8,1,2,3,4,5}; in decreasing order using function object. I did using lambda expression sort(v.begin(),v.end(),[](int a , int b){return a > b;}); But How we do using fn object

Member Avatar for mike_2000_17
0
269
Member Avatar for skyyadav

given int a[]= {3,2,7,6,8,1,4,5} vector<int> v(a,a+8) use the stl copy algorithm to display the last 5 integers in the vector to cout with each integer on a seperate line. copy takes three argument. third argument is output container. In this case it is v.but v already have 8 elemenst. How …

Member Avatar for mike_2000_17
0
190
Member Avatar for VUEKID

I need a little help to store two strings into a vector and reversing the order of each string. i.e. 123456789 needs to be 987654321 12345 needs to be 000054321 reason for that is I need to add those two numbers together.

Member Avatar for deceptikon
0
314
Member Avatar for skyyadav

I have to find the permutation of vector of integers. I need to implement and interleave function vector<vector<int> > interleave(int x , const vector<int> & v); Using interleave we can implement a permute function. vector<vector<int> > permute(size_t n); that returns a vector containing of the first n positive nos. I …

Member Avatar for skyyadav
0
146
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 Mantroskylo

This is an assingment i've been working on but since this is a merge between two previous developments i need a little help solving my issue here that would be highly appreciated. In a nutshell what this program needs to do is recieve a .txt file create a vector holding …

Member Avatar for rubberman
0
286

The End.