473,473 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

no match for 'operator=' in vector[][]

16 New Member
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <math.h>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main (void) {
  7.  
  8. int sv = 0, fv = 0;
  9.  
  10. cout << "Start Value:" << endl;
  11. cin >> sv;
  12. cout << "End Value:" << endl;
  13. cin >> fv;
  14. cout << endl;
  15.  
  16. int size = (int)sqrt(fv-sv)+5;
  17.  
  18. vector <vector<int> > grid [size][size];
  19. vector <vector<int> > grid2 [15][15];
  20.  
  21. int midx = (int)(sqrt(fv-sv)+5/2)-1, midy = (int)(sqrt(fv-sv)+5/2)-1;
  22. int down = 0, right = 0, left = 0, up = 0;
  23. int yy = 0, xx = 0;
  24. int count = 0;
  25. string dir = "down";
  26.  
  27. for (int i = 0; i <= 5 ; i++) {
  28.  
  29. if (dir=="down") {
  30. for (int i2 = 0; i2 < 1 ; i2++) {
  31. grid2[1][1] = 5;
  32. grid[0][0] = 5;
  33. grid [midx][midy] = i;
  34. }
  35. dir = "right";
  36. }
  37.  
  38. }
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. }
  46.  
When I compile the code above, I get this error "no match for 'operator=' in 'grid2[1][1] = 5' ". I'm clueless as to what's the problem... Thx!


31 C:\Documents and Settings\Administrator\Desktop\Testing Files Folder\J42001.cpp no match for 'operator=' in 'grid2[1][1] = 5'

note C:\Dev-Cpp\include\c++\3.4.2\bits\vector.tcc:131 candidates are: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<int, std::allocator<int> >, _Alloc = std::allocator<std::vector<int, std::allocator<int> > >]

32 C:\Documents and Settings\Administrator\Desktop\Testing Files Folder\J42001.cpp no match for 'operator=' in 'grid[0][0] = 5'
Feb 7 '09 #1
1 5439
orangemonkey
16 New Member
nvm.. i know what's the problem ...
i have to declare it like this vector <vector<int> > grid2(15, vector<int>(15));
Feb 7 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: KK | last post by:
Hi, im working on this bigInt class. Need help writing algorithm for the operator*, andy help will be appreciated. Thanks in advance bigInt.h...
21
by: Makhno | last post by:
Hello, Why does my cast from Vector<class Float> to Vector<float> not work? It won't compile, template<class Float> class Vector { public: Vector(Float x1,Float y1,Float...
51
by: Jojo | last post by:
Is there any way to get to the left-hand side of an operator? Consider the following (this is not meant to be perfect code, just an example of the problem): class Matrix { public: int data;...
2
by: Mr Dyl | last post by:
I'm having a few issues porting Windows code to Linux (VS.Net 2003 to GCC 4.0.1). So this probably has something to do with VS not catching non-compliant code. I'd like to simplify this problem,...
17
by: benben | last post by:
Given a class template Vector<>, I would like to overload operator +. But I have a hard time deciding whether the return type should be Vector<U> or Vector<V>, as in: template <typename U,...
0
by: santana | last post by:
Hi I've created a class to be used with stl vector. I'm having a hard time decipher the error message outpout by g++... burlen@quaoar:~/hdf52vtk_dev/src$ g++ junk.cpp GridPoint.o...
22
by: clicwar | last post by:
A simple program with operator overloading and copy constructor: #include <iostream> #include <string> using namespace std; class Vector { private: float x,y; public: Vector(float u, float...
4
by: abir | last post by:
I am matching a template, and specializing based of a template, rather than a single class. The codes are like, template<template<typename T,typename Alloc = std::allocator<T> class pix{ }; ...
4
by: fabian.lim | last post by:
Hi All, Im a newbie to C++, I am trying to customize the vector template STL to a template Class. My code is shown below. Im confused about something and maybe somebody here might be able to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.