Sponsored Content
Top Forums Programming Map with struct as key and vector as value Post 302917411 by yifangt on Tuesday 16th of September 2014 01:12:39 PM
Old 09-16-2014
Then comes to a new thing if two maps are used------they need share the key. While student_names only contains 3 unique entries(structure), student_courses contains 12 entries (structure) that are pushed into three vectors each for a student_names.
Do you mean to assign a new integer to both map?
The next step is to calculate the total credit of courses for each student; calculate the average grades for each student on his/her courses taken so far. So that I though use the string(or student ID) as key for retrieval and calculation.
The compiling error indicated the problem is the map iterator, which seems should be overloaded.
Code:
error: no match for 'operator=' in map_itr=mymap.std::map<_Key, _Tp, _Compare, _Alloc>::begin....
candidate is:
In file included from /usr/include/c++/4.7/map:60:0,
......

This challenge is too big for me at this moment. Thanks anyway!
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Pressing backspace key simulates enter key

Hi, Whenever i press the backspace key, a new line appears, i.e. it works like a enter key. :confused: Thanks (2 Replies)
Discussion started by: vibhor_agarwali
2 Replies

2. Programming

Vector Traversing

Hi i have the following structure struct S { char Mod_num; char val; char chr_nm_cd; } I am reading a 2GB file and inserting into the structure and writing into a vector. I feel like only vector will be a right option. I tried with multimap but it is memory intensive and hence i... (1 Reply)
Discussion started by: dhanamurthy
1 Replies

3. UNIX for Dummies Questions & Answers

How to access a struct within a struct?

Can someone tell me how to do this? Just a thought that entered my mind when learning about structs. First thought was: struct one { struct two; } struct two { three; } one->two->three would this be how you would access "three"? (1 Reply)
Discussion started by: unbelievable21
1 Replies

4. Programming

C++ Map using a Vector as a Value Type?

I modified some code I found on Wikipedia concerning maps to see if it would work before applying it to a project I'm working on that has a similar idea. What I would want is for a user to be able to enter sentences and then be able to distinguish how many times a the person entered a word in a... (4 Replies)
Discussion started by: kcgb20
4 Replies

5. Solaris

Solaris 8 ssh public key authentication issue - Server refused our key

Hi, I've used the following way to set ssh public key authentication and it is working fine on Solaris 10, RedHat Linux and SuSE Linux servers without any problem. But I got error 'Server refused our key' on Solaris 8 system. Solaris 8 uses SSH2 too. Why? Please help. Thanks. ... (1 Reply)
Discussion started by: aixlover
1 Replies

6. Programming

Storing C++-struct in file - problem when adding new item in struct

Hi, I have received an application that stores some properties in a file. The existing struct looks like this: struct TData { UINT uSizeIncludingStrings; // copy of Telnet data struct UINT uSize; // basic properties: TCHAR szHost; //defined in Sshconfig UINT iPortNr; TCHAR... (2 Replies)
Discussion started by: Powerponken
2 Replies

7. Programming

Array and Vector

Hi all, from my understanding I understand that I can use array in this manner. struct test { int a; int b; int c; }; test testing; //creating an array with the structer type testing.a=1; testing.b=2; testing.c=3; If I'm not wrong we can use array in this manner,... (12 Replies)
Discussion started by: vinzping
12 Replies

8. Programming

vector c++

hello guys. i'm new to c++. i've problem using two dimensional vector. i've a project of making conway's game of life. this is the code that i have made so far. my problem is how can i give a two dimensional vector through main. glider.vec1 = vec; is not correct way to give a two... (2 Replies)
Discussion started by: nishrestha
2 Replies

9. Shell Programming and Scripting

Vector normalisation

In AWK For 3 individual vectors of the form: -2.772 -9.341 -2.857 -5.140 -6.597 -1.823 -2.730 -5.615 1.159 I would like to write a script that parses line by line to (i) normalise, (ii) divide by the norm for *each* vector. I.e. sqrt(-2.772^2 + -9.341^2 + -2.857^2)=10.154 ... (4 Replies)
Discussion started by: chrisjorg
4 Replies
QMapIterator(3qt)														 QMapIterator(3qt)

NAME
QMapIterator - Iterator for QMap SYNOPSIS
#include <qmap.h> Public Members typedef std::bidirectional_iterator_tag iterator_category typedef T value_type typedef T * pointer typedef T & reference QMapIterator () QMapIterator ( QMapNode<K, T> * p ) QMapIterator ( const QMapIterator<K, T> & it ) bool operator== ( const QMapIterator<K, T> & it ) const bool operator!= ( const QMapIterator<K, T> & it ) const T & operator* () const T & operator* () const const K & key () const T & data () const T & data () const QMapIterator<K, T> & operator++ () QMapIterator<K, T> operator++ ( int ) QMapIterator<K, T> & operator-- () QMapIterator<K, T> operator-- ( int ) DESCRIPTION
The QMapIterator class provides an iterator for QMap. You cannot create an iterator by yourself. Instead, you must ask a map to give you one. An iterator is as big as a pointer; on 32-bit machines that means 4 bytes, on 64-bit machines, 8 bytes. That makes copying iterators very fast. Iterators behave in a similar way to pointers, and they are almost as fast as pointers. See the QMap example. QMap is highly optimized for performance and memory usage, but the trade-off is that you must be more careful. The only way to traverse a map is to use iterators. QMap does not know about its iterators, and the iterators don't even know to which map they belong. That makes things fast but a bit dangerous because it is up to you to make sure that the iterators you are using are still valid. QDictIterator will be able to give warnings, whereas QMapIterator may end up in an undefined state. For every Iterator there is also a ConstIterator. You must use the ConstIterator to access a QMap in a const environment or if the reference or pointer to the map is itself const. Its semantics are the same, but it only returns const references to the item it points to. See also QMap, QMapConstIterator, Qt Template Library Classes, and Non-GUI Classes. Member Type Documentation QMapIterator::iterator_category The type of iterator category, std::bidirectional_iterator_tag. QMapIterator::pointer Pointer to value_type. QMapIterator::reference Reference to value_type. QMapIterator::value_type The type of value. MEMBER FUNCTION DOCUMENTATION
QMapIterator::QMapIterator () Creates an uninitialized iterator. QMapIterator::QMapIterator ( QMapNode<K, T> * p ) Constructs an iterator starting at node p. QMapIterator::QMapIterator ( const QMapIterator<K, T> & it ) Constructs a copy of the iterator, it. T &; QMapIterator::data () Returns a reference to the current item's data. const T &; QMapIterator::data () const This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Returns a const reference to the current item's data. const K &; QMapIterator::key () const Returns a const reference to the current item's key. bool QMapIterator::operator!= ( const QMapIterator<K, T> & it ) const Compares the iterator to the it iterator and returns FALSE if they point to the same item; otherwise returns TRUE. T &; QMapIterator::operator* () Dereference operator. Returns a reference to the current item's data. The same as data(). const T &; QMapIterator::operator* () const This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Dereference operator. Returns a const reference to the current item's data. The same as data(). QMapIterator<;K, T> & QMapIterator::operator++ () Prefix ++ makes the succeeding item current and returns an iterator pointing to the new current item. The iterator cannot check whether it reached the end of the map. Incrementing the iterator returned by end() causes undefined results. QMapIterator<;K, T> QMapIterator::operator++ ( int ) This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Postfix ++ makes the succeeding item current and returns an iterator pointing to the new current item. The iterator cannot check whether it reached the end of the map. Incrementing the iterator returned by end() causes undefined results. QMapIterator<;K, T> & QMapIterator::operator-- () Prefix -- makes the previous item current and returns an iterator pointing to the new current item. The iterator cannot check whether it reached the beginning of the map. Decrementing the iterator returned by begin() causes undefined results. QMapIterator<;K, T> QMapIterator::operator-- ( int ) This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Postfix -- makes the previous item current and returns an iterator pointing to the new current item. The iterator cannot check whether it reached the beginning of the map. Decrementing the iterator returned by begin() causes undefined results. bool QMapIterator::operator== ( const QMapIterator<K, T> & it ) const Compares the iterator to the it iterator and returns TRUE if they point to the same item; otherwise returns FALSE. SEE ALSO
http://doc.trolltech.com/qmapiterator.html http://www.trolltech.com/faq/tech.html COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. AUTHOR
Generated automatically from the source code. BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qmapiterator.3qt) and the Qt version (3.1.1). Trolltech AS 9 December 2002 QMapIterator(3qt)
All times are GMT -4. The time now is 03:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy