Click here to Skip to main content
15,885,782 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Error --------- missing storage-class or type specifiers (for class) Pin
CPallini4-Dec-07 1:07
mveCPallini4-Dec-07 1:07 
QuestionWindow Status Pin
nitin33-Dec-07 19:28
nitin33-Dec-07 19:28 
GeneralRe: Window Status Pin
David Crow4-Dec-07 7:16
David Crow4-Dec-07 7:16 
Questioncan i create a dll, what includes other dlls? Pin
mwolf1223-Dec-07 19:16
mwolf1223-Dec-07 19:16 
AnswerRe: can i create a dll, what includes other dlls? Pin
Hamid_RT3-Dec-07 19:43
Hamid_RT3-Dec-07 19:43 
AnswerRe: can i create a dll, what includes other dlls? Pin
Matthew Faithfull4-Dec-07 1:34
Matthew Faithfull4-Dec-07 1:34 
AnswerRe: can i create a dll, what includes other dlls? Pin
malaugh5-Dec-07 11:13
malaugh5-Dec-07 11:13 
GeneralDeferencing a vector of vectors in a nested for loop Pin
Caudata3-Dec-07 18:44
Caudata3-Dec-07 18:44 
I am by no means an experienced c++ programmer, but am trying to store multiple occurances of 3 strings in a vector of vectors and need to reference the stored values from a nested for loop. I can't seem to stumble or fumble onto the correct syntax. Below is a short example that I am using as a test case.

<br />
#include <iostream><br />
#include <string><br />
#include <vector><br />
<br />
using namespace std;<br />
<br />
struct s {<br />
	string strA;<br />
	string strB;<br />
	string strC;<br />
};<br />
<br />
void main (int argc, char *argv[]) {<br />
<br />
typedef vector <s> vstype;<br />
vstype v;<br />
<br />
	s bugs;<br />
	bugs.strA="bees";<br />
	bugs.strB="beetles";<br />
	bugs.strC="flys";<br />
<br />
	v.push_back(bugs);<br />
<br />
	s bugs2;<br />
	bugs2.strA="chiggers";<br />
	bugs2.strB="moths";<br />
	bugs2.strC="praying mantii";<br />
<br />
	v.push_back(bugs2);<br />
	<br />
	bugs.strA="mosquitos";<br />
	bugs.strB="ants";<br />
	bugs.strC="ticks";<br />
<br />
	v.push_back(bugs);<br />
<br />
	cout << bugs.strA << endl << endl;<br />
	<br />
	string dummy = bugs.strA;<br />
<br />
<br />
	for( vstype::const_iterator p=v.begin(); p!=v.end(); ++p) {<br />
 		cout << "3 BUGS" << endl << (*p).strA << endl << (*p).strB << endl << (*p).strC << endl << endl;<br />
	}<br />
<br />
	v.clear();<br />
<br />
	for( p=v.begin(); p!=v.end(); ++p) {<br />
 		cout << "3 BUGS" << endl << (*p).strA << endl << (*p).strB << endl << (*p).strC << endl << endl;<br />
	}<br />
<br />
	cout << "===============" << endl << endl;<br />
<br />
vector <vstype> vx;<br />
<br />
	vx.push_back(v);<br />
<br />
	v[0].strA="aphids";<br />
	v[0].strB="stink bugs";<br />
	v[0].strC="dragonflys";<br />
<br />
	vx.push_back(v);<br />
<br />
	// How do you properly dereference the individual items in the following nested for loop to print all values of strings in the vector of vectors?<br />
	// I am assuming that you do not need to use the vector[x][y] notation.<br />
	for (vector<vstype>::const_iterator s=vx.begin(); s!=vx.end(); s++) {<br />
		for (p=(*s).begin(); p!=(*s).end(); p++) {<br />
			cout << (*s)[0] << endl;<br />
		}<br />
		cout << endl;<br />
	}<br />
<br />
}<br />


I realize that I might be able to dereference with some sort of vs[x][y] notation, but was trying to get it to work this way just for grins.

Any suggestions would be greatly appreciated. Thanks.
GeneralRe: Deferencing a vector of vectors in a nested for loop Pin
CPallini4-Dec-07 0:59
mveCPallini4-Dec-07 0:59 
GeneralOverwrite a file Pin
john56323-Dec-07 18:41
john56323-Dec-07 18:41 
GeneralRe: Overwrite a file Pin
toxcct4-Dec-07 1:10
toxcct4-Dec-07 1:10 
GeneralRe: Overwrite a file Pin
Nelek4-Dec-07 21:41
protectorNelek4-Dec-07 21:41 
GeneralRe: Overwrite a file Pin
Nelek4-Dec-07 21:42
protectorNelek4-Dec-07 21:42 
QuestionApplication Error... Pin
Priya_Sundar3-Dec-07 18:40
Priya_Sundar3-Dec-07 18:40 
GeneralRe: Application Error... Pin
john56323-Dec-07 18:45
john56323-Dec-07 18:45 
GeneralRe: Application Error... Pin
Hamid_RT3-Dec-07 19:40
Hamid_RT3-Dec-07 19:40 
GeneralRe: Application Error... Pin
Jijo.Raj4-Dec-07 2:23
Jijo.Raj4-Dec-07 2:23 
GeneralRe: Application Error... Pin
David Crow4-Dec-07 7:19
David Crow4-Dec-07 7:19 
GeneralIncorrect position in screen Pin
kk.tvm3-Dec-07 18:29
kk.tvm3-Dec-07 18:29 
GeneralRe: Incorrect position in screen Pin
Nelek4-Dec-07 21:40
protectorNelek4-Dec-07 21:40 
GeneralExecute inline query with database connection in C++ Pin
CodingLover3-Dec-07 18:11
CodingLover3-Dec-07 18:11 
GeneralRe: Execute inline query with database connection in C++ Pin
wira1guys3-Dec-07 20:38
wira1guys3-Dec-07 20:38 
GeneralRe: Execute inline query with database connection in C++ Pin
CodingLover4-Dec-07 18:30
CodingLover4-Dec-07 18:30 
GeneralRe: Execute inline query with database connection in C++ Pin
wira1guys4-Dec-07 20:07
wira1guys4-Dec-07 20:07 
QuestionHow can i access my fat table of hard drive through codding Pin
Naveed7273-Dec-07 17:58
Naveed7273-Dec-07 17:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.